Reputation: 21
I'm writing to inquire a bout a problem when I'm using iText library to extract text contents from PDF file.I would able to extract all the text, but couldn't find the method to extract font styles.
Upvotes: 1
Views: 1779
Reputation: 617
To get the fontsize of a font in itext, use this code:
renderInfo.getAscentLine().getStartPoint().get(1)-
renderInfo.getDescentLine().getStartPoint().get(1)
This will give you the exact fontsize.
Upvotes: 1
Reputation: 77576
First you need to read the answer to this question: how can i get text formatting with iTextSharp
In this question, you'll discover that the TextRenderInfo
has a getFont()
method that allows you to get the PostScriptFontName. If you are in luck, this PostScriptFontName will give you information about the style.
Note that this won't always work. Please read the answer to this question: What are the ways of checking if piece of text in PDF documernt is bold using iTextSharp
That question shows an example of a font that doesn't reveal anything about its style.
Upvotes: 1