Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Add Watermark behind PDF Text |
Post Reply |
Author | |
chrisreed
Team Player Joined: 29 Apr 13 Location: Australia Status: Offline Points: 35 |
Post Options
Thanks(0)
Posted: 18 Jun 13 at 9:28AM |
I followed the QuickPDF example on how to add a Watermark to an existing PDF Document which all worked fine, except the Watermark was inserted infront of the existing PDF text.
How can I insert the watermark behind the existing PDF text.
See link below to which shows the difference....
NOTE: Making the watermark semi-transparent is not the affect I am really after.
Chris
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Chris!
That's heavy stuff! There's no sample here. You should read about layers and (optional) content groups in the reference. You have to recreate the whole document for this (taking the layers away... drawing the watermark... then the layers back... puuuuh :) Nearly the same and much easier it is to put a bit more transparency to the watermark ;-) Cheers, Ingo |
|
chrisreed
Team Player Joined: 29 Apr 13 Location: Australia Status: Offline Points: 35 |
Post Options
Thanks(0)
|
Damn. I was hoping there was a Method like "Appear Behind Text" or something similar.
How do I put in request for a Method like this be added to the next version as I feel it is a very useful feature for things like Watermarks.
As for adding more transparency I'm in a Catch-22 situation. I have to add more transparency so I can see the text behind the watermark, but if I make it too transparent then the Watermark does not come out if the report is photocopied - maybe I can get away with a happy compromise.
Thanks Ingo for the reply.
|
|
chrisreed
Team Player Joined: 29 Apr 13 Location: Australia Status: Offline Points: 35 |
Post Options
Thanks(0)
|
Hi again,
There was a post that explained how to insert text behind text using Streams (see link) which I thought I could use with my Watermark issue.
My original PDF seemed to have two ContentStreams and I created a NewContentStream (No. 3) added the image and then used the MoveContentStream function to move it from Stream 3 to Stream 1. But it didn't matter what streams I moved around or where I added the image (before or after a NewStream was created) the watermark always appeared on top of the original text.
Can my issue be solved using ContentStreams?
Chris
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Can my issue be solved using ContentStreams? Hi Chris! That's what i told. Cheers, Ingo
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
You could try something along the lines of the following which I have adapted from http://www.quickpdf.org/forum/inserting-text-behind-existing-text_topic2570_post10615.html?KW=behind+text#10615 QP.LoadFromFile (... QP.SelectPage(1); int cs = NewContentStream(); QP.SetOrigin(1); int img = QP.AddImageFromFile("myimage.png", 0); QP.DrawImage(0,0,QP.PageWidth(), QP.PageHeight(); QP.MoveContentStream(cs, 1); QP.SaveToFile("newfile.pdf"); Moving the content stream with the image to content stream 1 will mean that the image is draw first and that any test or other logos will be drawn on top. Whether this approach works or not will depend on how the PDF is created. If the first command of the PDF is to draw and fill a white rectangle the same size as the page then this approach will not work. If this doesn't work then you will need to post some code so we can understand what is and isn't working. Andrew
|
|
chrisreed
Team Player Joined: 29 Apr 13 Location: Australia Status: Offline Points: 35 |
Post Options
Thanks(0)
|
Ha! Ha! That's the exact same link I mentioned above My code is based on your example Andrew - it sort of worked for some PDF's but not for others (see my code below).
If I converted a Word document into a PDF using PDF Creator it worked, however if I used a PDF created from a hospital application and moved it to Stream 1, the watermark didn't even appear!!
If I moved it to Stream 2, the Watermark appeared in both PDF's but always infront of the text.
In both cases the ContentStreamCount was three. How do I tell if the first command is to draw and fill a white rectangle - could that be the issue?
Unfortunately I can't attach the problematic PDF report because it has patient information on it.
Chris
|
|
chrisreed
Team Player Joined: 29 Apr 13 Location: Australia Status: Offline Points: 35 |
Post Options
Thanks(0)
|
As Andrew mentioned in his previous post, the reason it wasn't working was that the first command in the PDF File was to draw a white rectangle.
This can be found using GetPageContentToString (or GetPageContentToVariant - ActiveX version) and you will see something like this at the top of the file.
1 g // select White - 0 2.66797 4956 7014 re // create a rectangle f // fill the rectangle with the white pen And the reason for this was I was printing the PDF indirectly through a Web-based application and not directly through the PDFCreator application.
Chris |
|
mat miller
Beginner Joined: 21 Jan 13 Status: Offline Points: 3 |
Post Options
Thanks(0)
|
I wonder can you achieve similar effect by adjusting the watermark transparency.
http://www.quickpdf.org/forum/watermark_topic230.html http://stackoverflow.com/questions/2913934/use-php-how-i-can-add-watermark-to-pdf |
|
chrisreed
Team Player Joined: 29 Apr 13 Location: Australia Status: Offline Points: 35 |
Post Options
Thanks(0)
|
Hi Mat,
Yes I did try that, but its a Catch-22 situation. I needed to make the Watermark transparent enough so I can still see the text/images behind it, but not too transparent that the Watermark is hard to read.
I could not find a suitable compromise between these two conflicting requirements which is why it MUST be placed behind the text/images.
Chris
|
|
lucy142
Beginner Joined: 24 Mar 15 Location: U.S Status: Offline Points: 1 |
Post Options
Thanks(0)
|
Hi Friends, To add watermark behind pdf text you can go with this
perfect PDF watermark for mac software solution to add text/image
watermark to every page of a PDF file or behind PDF Text. It facilities you
with the realtime preview output effect, Batch watermark PDF
files like amazing features. For any information about this software you can visit to this link: http://www.completepdfsolultions.com/pdf-watermark-mac.php |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store