Basically I want to perform PDF validations, My pdfs involve headers, footers, watermarks etc. I need to know how do we retrieve above fields from existing pdf using pdfbox? How do we distinguish between regular image & watermarked img? Is is possible via pdfbox apis such as [ Image.isWatermarkedImage() ]?
I have seen examples to add such things but none of them speaks about retrieval.

- 11
- 1
- 5
1 Answers
I want to perform PDF validations, My pdfs involve headers, footers, watermarks etc. I need to know how do we retrieve above fields from existing pdf using pdfbox?
Your question shows some misconceptions: In a generic PDF document there are no headers, footers, or watermarks, there is only content.
Even though the PDF specification includes mechanisms to mark content to express such uses, this marking is optional and, therefore, nothing you can expect in general.
As you say you want to perform PDF validations, though, you might have some influence on the PDF production process or at least on the validation criteria. If that is the case, you can try and require these document parts to be marked accordingly. In that case we can try and go into detail concerning what exactly to require beforehand and how to find and check such marked parts.
How do we distinguish between regular image & watermarked img?
Cf. this answer on how watermark images may be recognized. In essence: In general you cannot recognize them for sure.
-
Ok. Actually I myself am going to create those PDFs & I am going to write code for its validation. As you said We could use mark the content during creation so that we could identify specific PDF component during content retrieval or validation process. Could we add marks to headers, footers, watermarks, bookmarks while creation of same? Are there any examples of same? – Ameya Bapat Apr 03 '14 at 06:30
-
Which library do you use for PDF creation? You mentioned PDFBox as library you wanted to use for validation, do you want to use it for creation, too? – mkl Apr 03 '14 at 12:55
-
Yes, PDFBox is fine for me. – Ameya Bapat Apr 03 '14 at 15:18