I downloaded your file and uncompressed it using pdftk. After that I just
opened it with a text editor and looked for anything which might be
interesting.
I found that there's an element which mentions something about an image
and transparency.
2 0 obj
<<
/Rotate 0
/pdftk_PageNum 1
/CropBox [0 0 612 792]
/MediaBox [0 0 612 792]
/Resources
<<
/ExtGState
<<
/GS8 21 0 R
/GS5 22 0 R
>>
/Font
<<
/F1 23 0 R
>>
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
>>
/Parent 1 0 R
/Contents [24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0
R]
/StructParents 0
/Type /Page
/Group
<<
/CS /DeviceRGB
/Type /Group
/S /Transparency
>>
/Tabs /S
>>
endobj
Tracing back, it turns out that this is the page element ("20 0" is the
root, "1 0" is the element which defines the pages, and "2 0" is page 1).
Now the /Contents of the page are what we're interested in, but
unfortunately they are all streams of data which means very little to me.
I'm not sure if these are object streams, but I'd imagine so because there
doesn't seem to be any indication of the type. If you can find a way to
get these in a more human-readable format, you should be able to continue
reverse engineering the PDF to determine how the image is on there. Once
you know that, you'll know exactly what you want to do. Then it should
just be a matter of checking the PDF reference to fully understand what's
going on and what output you need from PDFBox. It's important you get
comfortable with tracing through a PDF in a text editor; this is the only
way you'll be able to track down issues.
I usually just search the PDF source for the keyword that I'm looking for
when I'm looking for a new feature and then trace the code back to try to
understand how it is used and what the key classes are. Once I know what
classes to use, I hit the documentation and search the Internet for
examples. If that doesn't work, check the user mailing list and see if
anyone has any suggestions. If not, check the dev mailing list to see if
the functionality currently exists and if not, if anyone has any
suggestions on where you should implement it.
----
Thanks,
Adam
From:
"Hesham G." <[email protected]>
To:
<[email protected]>
Date:
06/16/2011 07:34
Subject:
Re: Is there a difference between Watermark & Stamp ?
Adam ,
This post is old, but I am still facing problems using the watermark, and
I need it badly.
I have created a Microsoft word doc file with a watermark and I saved it
as a PDF file, and it appears just as I want. Now I am looking for a way
for how to do this with PDFBox. You can check this 1 page sample PDF :
http://www.4shared.com/document/rQ2berMh/pdf_with_watermark.html
Any help would be appreciated.
Best regards ,
Hesham
---------------------------------------------
Included message :
> Sorry, but I can't give you any code examples for I have never done any
> work with stamps nor watermarks. All I did was read the manual because
> when I saw your question I thought "Hmm, that's a good question!"
>
> What you describe sounds correct in terms of how it works, but it looks
> like there is also an option to have the watermark not appear at all on
> the PDF (when rendered on the screen), but appear when it is printed.
I'm
> not sure if that's something you are interested in, but it's an option
as
> far as I can tell.
>
> Your best bet would be to find a PDF with a watermark, then extract a
> single page. This will give you a small PDF with a watermark and you
> should be able to go through it by hand (i.e. a good text editor). Just
> search for "watermark" and see what comes up and then when you find
> something in the PDF, see what references it and check the spec to get
> some more information about what you're looking at. For example, if you
> see object "72 0" is a watermark, search for things which reference 72
0.
> If you keep doing this you'll eventually get back to the root. If you
> keep notes, you should have a nice map of how everything is connected.
> I've done this for other objects and in combination with the spec, it's
> worked out pretty well. Remember, you can also make modifications to
the
> PDF using a text editor to see what it does (just remember to back up
the
> original before you go hacking up the PDF or you'll probably end up with
a
> corrupt document).
>
> ----
> Thanks,
> Adam
>
>
>
> From:
> "Hesham G." <[email protected]>
> To:
> <[email protected]>
> Date:
> 11/11/2010 03:15
> Subject:
> Re: Is there a difference between Watermark & Stamp ?
>
>
>
> Adam ,
>
> Thanks a lot for you reply, and sorry for being that late ... You're
> always
> here Adam when I need an answer.
>
> I have this in PDF reference 1.7, but I do not understand that Adobe
code
> :)
> If you can translate this to me or give me a PDFBox code example, that
> will
> be very helpful.
>
> In general, what I understand is that both watermarks and stamps both
can
> be
> images that appear in the PDF, but a watermark will appear in the
> background, so if there was a text above it, the text will appear
> normally.
> In addition a watermark will appear as a part of the page, so it can't
be
> clicked to show a notice box, as happens in a Stamp.
>
> If this is wrong I hope you can correct me. if it's right, then
watermarks
>
> is what I am looking for.
>
> Best regards ,
> Hesham
>
> ---------------------------------------------
> Included message :
>
>> Hesham,
>>
>> Take a look at table 102 in section 8.11.4.4 (Usage and Usage
> Application
>> Dictionaries) of the PDF spec (I'm looking at version 1.7).
>> "A dictionary specifying that the content in this group is shall be
used
>> when printing. It may contain the following optional entries:
>> Subtype A name object specifying the kind of content controlled by the
>> group; for example, Trapping, PrintersMarks and Watermark.
>> PrintState A name that shall be either ON or OFF, indicating that the
>> group shall be set to that state when the document is printed from a
>> conforming reader."
>>
>> For more information on the subtypes, see section 12.5.6.1, and
> 12.5.6.22
>> for specific details about a watermark.
>>
>> I didn't read all the sections I just references, but after a quick
> look,
>> it seems the main difference is that watermarks only appear on printed
>> documents, where images would appear when viewing the document as well.
>> PDFBox might already support watermarks, but if it doesn't it could
>> probably be added without too much difficulty. Section 12.5.6.22 has a
>> nice example of how it's laid out in the PDF which you could reference.
>> You could also use that to either verify that your test document
> actually
>> has a real watermark, or to manually add a watermark to one of your
test
>> documents.
>>
>> ----
>> Thanks,
>> Adam
>>
>>
>> ----- Forwarded by Adam Nichols/UR/CER/XLDynamics on 11/09/2010 12:04
>> -----
>>
>> From:
>> Adam Nichols/UR/CER/XLDynamics
>> To:
>> [email protected]
>> Cc:
>> "pdfbox-send-question" <[email protected]>
>> Date:
>> 11/08/2010 09:13
>> Subject:
>> Re: Is there a difference between Watermark & Stamp ?
>>
>>
>> Take a look at table 102 in section 8.11.4.4 (Usage and Usage
> Application
>> Dictionaries) of the PDF spec (I'm looking at version 1.7).
>> "A dictionary specifying that the content in this group is shall be
used
>> when printing. It may contain the following optional entries:
>> Subtype A name object specifying the kind of content controlled by the
>> group; for example, Trapping, PrintersMarks and Watermark.
>> PrintState A name that shall be either ON or OFF, indicating that the
>> group shall be set to that state when the document is printed from a
>> conforming reader."
>>
>> For more information on the subtypes, see section 12.5.6.1, and
> 12.5.6.22
>> for specific details about a watermark.
>>
>> I didn't read all the sections I just references, but after a quick
> look,
>> it seems the main difference is that watermarks only appear on printed
>> documents, where images would appear when viewing the document as well.
>> PDFBox might already support watermarks, but if it doesn't it could
>> probably be added without too much difficulty. Section 12.5.6.22 has a
>> nice example of how it's laid out in the PDF which you could reference.
>> You could also use that to either verify that your test document
> actually
>> has a real watermark, or to manually add a watermark to one of your
test
>> documents.
>>
>> ----
>> Thanks,
>> Adam
>>
>>
>>
>> From:
>> "Hesham G." <[email protected]>
>> To:
>> "pdfbox-send-question" <[email protected]>
>> Date:
>> 11/07/2010 00:53
>> Subject:
>> Is there a difference between Watermark & Stamp ?
>>
>>
>>
>> Hello everyone ,
>>
>> What is the difference between a watermark and a stamp in PDF ?
>> I have seen nice examples in PDFBox to create stamps, but none to
create
>> watermarks. I guess it is not supported yet !
>>
>>
>> Best regards ,
>> Hesham
>>
>>
>>
>>
>>
>> - FHA 203b; 203k; HECM; VA; USDA; Conventional
>> - Warehouse Lines; FHA-Authorized Originators
>> - Lending and Servicing in over 45 States
>> www.swmc.com - www.simplehecmcalculator.com
>> Visit www.swmc.com/resources for helpful links on Training,
Webinars,
>
>> Lender Alerts and Submitting Conditions
>>
>> This email and any content within or attached hereto from Sun West
>> Mortgage Company, Inc. is confidential and/or legally privileged. The
>> information is intended only for the use of the individual or entity
> named
>> on this email. If you are not the intended recipient, you are hereby
>> notified that any disclosure, copying, distribution or taking any
action
>
>> in reliance on the contents of this email information is strictly
>> prohibited, and that the documents should be returned to this office
>> immediately by email. Receipt by anyone other than the intended
> recipient
>> is not a waiver of any privilege. Please do not include your social
>> security number, account number, or any other personal or financial
>> information in the content of the email. Should you have any questions,
>> please call (800) 453 7884. =
>
>
>
>
>
>
> - FHA 203b; 203k; HECM; VA; USDA; Conventional
> - Warehouse Lines; FHA-Authorized Originators
> - Lending and Servicing in over 45 States
> www.swmc.com - www.simplehecmcalculator.com
> Visit www.swmc.com/resources for helpful links on Training, Webinars,
Lender Alerts and Submitting Conditions
>
> This email and any content within or attached hereto from Sun West
Mortgage Company, Inc. is confidential and/or legally privileged. The
information is intended only for the use of the individual or entity named
on this email. If you are not the intended recipient, you are hereby
notified that any disclosure, copying, distribution or taking any action
in reliance on the contents of this email information is strictly
prohibited, and that the documents should be returned to this office
immediately by email. Receipt by anyone other than the intended recipient
is not a waiver of any privilege. Please do not include your social
security number, account number, or any other personal or financial
information in the content of the email. Should you have any questions,
please call (800) 453 7884. =
- FHA 203b; 203k; HECM; VA; USDA; Conventional
- Warehouse Lines; FHA-Authorized Originators
- Lending and Servicing in over 45 States
www.swmc.com - www.simplehecmcalculator.com Visit www.swmc.com/resources
for helpful links on Training, Webinars, Lender Alerts and Submitting
Conditions
This email and any content within or attached hereto from Sun West Mortgage
Company, Inc. is confidential and/or legally privileged. The information is
intended only for the use of the individual or entity named on this email. If
you are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution or taking any action in reliance on the
contents of this email information is strictly prohibited, and that the
documents should be returned to this office immediately by email. Receipt by
anyone other than the intended recipient is not a waiver of any privilege.
Please do not include your social security number, account number, or any other
personal or financial information in the content of the email. Should you have
any questions, please call (800) 453 7884.