Aspose pdf- floating box change font size or font name

Hi.

Can I change Font size and font name with a floating box?

Hi Michal,


Thanks for your inquiry. I am afraid you can not access a floating box in an existing PDF document directly and change the font settings. However if you know the coordinates of the specific area then you can change font and font size as following.

Moreover, please note as described in documentation that Point is measuring unit of Aspose Pdf and 72 points=1 Inch=25.4 mm. In case of A4 page size, coordinates of lower left corner are (0,0) and top right corner are (594,841) in points.

//open document<o:p></o:p>

Document pdfDocument = new Document(myDir + "input.pdf");

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();

textFragmentAbsorber.TextSearchOptions.LimitToPageBounds = true;

textFragmentAbsorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(90, 190, 255, 345);

//accept the absorber for desired page number search

pdfDocument.Pages[1].Accept(textFragmentAbsorber);

//get the extracted text fragments

TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

//loop through the fragments

foreach (TextFragment textFragment in textFragmentCollection)

{

Console.WriteLine("Text : {0} ", textFragment.Text);

textFragment.TextState.Font = FontRepository.FindFont("Arial");

textFragment.TextState.FontSize=16;

}

pdfDocument.Save(myDir + "output.pdf");

Please feel free to contact us for any further assistance.


Best Regards,