Getting Font Size of the Text In the PDF File

Skip to end of metadata
Go to start of metadata
Getting Font Size of the Text In the PDF File

Aspose.Pdf.Kit for Java allows you to get the font size of the particular text segment in a PDF file. You can get all the text segments along with the font size. Please note that these segments are as defined by the PDF specification. An array of TextSegment objects can be retrieved using getFormattedText method of PdfExtractor class. This TextSegment array contains a list of text segments along with the font sizes.
The following example shows you how to get the font size of all the text segments:

[Java]
//create PdfExtractor object
PdfExtractor pdfExtractor = new PdfExtractor();
//bind PDF file
pdfExtractor.bindPdf("input.pdf");
//extract text
pdfExtractor.extractText();
//get formatted text
TextSegment[] result = pdfExtractor.getFormattedText();
//get actual text and font size
for (int i = 0; i < result.length; i++)
{
   System.out.println(result[i].getText() + " " + result[i].getFontSize());
}
 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.