You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Qingchao Kong <kq...@gmail.com> on 2016/07/28 01:27:10 UTC

Detect headers of PDF

Hi, I want to detect the headers of PDF docs.

In my PDF files, I notice that, usually the headers of PDF and the
main text body are separated  by a horizontal line. Is it possible to
detect this "line" using Java code?

If this is possible, so I can get the rectangle of the main text area
and remove the headers automatically using Java code.

Regards,

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Detect headers of PDF

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 28.07.2016 um 03:27 schrieb Qingchao Kong:
> Hi, I want to detect the headers of PDF docs.
>
> In my PDF files, I notice that, usually the headers of PDF and the
> main text body are separated  by a horizontal line. Is it possible to
> detect this "line" using Java code?

Yes but this is tricky, PDF does not have a <HEADER>. Have a look here:
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/RemoveAllText.java?view=markup

This does something else, but the principle is the same: Analyze the 
content stream.

To understand what the PDF operators do, get the PDF 32000 specification
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
and go to the segment "operator summary".

If you're lucky, the line is really a line, i.e. operators m and l. If 
not lucky, it is a small image, or a rectangle.

Tilman

>
> If this is possible, so I can get the rectangle of the main text area
> and remove the headers automatically using Java code.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org