Get fonts information from PDF document in C#/Java using Aspose.PDF

@priyanga

Thanks for getting back to us.

Please note that, above is the size of array i.e. ByteArrayOutputStream baos where font file is saved, not the size of font itself. However, would you please confirm if you want to retrieve font size from existing PDF document. We will check the details at our side and provide our feedback accordingly. In case you want file size in MB or KB units, you can convert byte size as baos.size()/(1024*1024) and baos.size()/1024, respectively.

1 Like

Hi,

I tried this code and it threw an error "ā€˜Aspose.Pdf.Documentā€™ does not contain an definition for ā€œFontUtilitiesā€. Iā€™m using Aspose.PDF .Net. Any help is appreciated.

Thanks,
AR

@adzapp

The Aspose.Pdf.Document contains FontUtilities property in newer versions of the API. Would you kindly make sure to use latest version of the API and in case you still face any issue, please let us know.

Hi,

I want to retrieve font size from existing PDF document. Is there any update on this please?

@jainmuk

Do you want to retrieve the size of the font stream/file embedded into an existing file? OR do you want to determine the text size? Please share a bit more details so that we can provide related information.

Hi Asad,

I want to retrieve the fontsize from the pdf fie. there is no embedded file.

@jainmuk

Please try to use the below code snippet in order to get the fontsize of the text inside a PDF:

Document doc = new Document(dataDir + "file.pdf");
TextFragmentAbsorber tfa = new TextFragmentAbsorber();
doc.getPages().get_Item(1).accept(tfa);
for(TextFragment tf : tfa.getTextFragments()){
 System.out.println(tf.getTextState().getFontSize());
}