Alimur Razi Rana
Alimur Razi Rana

Reputation: 87

How to find a word's page number and font size in PDF?

I want to search a word in PDF, and I want what page it stays and there the word’s font size by java code. I use itext so is it possible by itext? If not what library can be used for this purpose?

Upvotes: 0

Views: 90

Answers (1)

mkl
mkl

Reputation: 95953

I want to search a word in pdf , and I want what page it stays and there the word’s font size by java code. I use itext so is it possible by itext ?

This is possible using iText. Have a look at the iText 5.5.x com.itextpdf.text.pdf.parser package or the iText 7.0.x kernel com.itextpdf.kernel.pdf.canvas.parser package.

To retrieve the font size, you'll have to extend existing text extraction strategies or create your own from scratch. Inspect the TextRenderInfo you get in the strategy callback method to find the font size.

Try this. If you have a tangible problem while implementing that, extend your question accordingly or ask a new one.

Upvotes: 1

Related Questions