Print Page | Close Window

Inserting text behind existing text

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2570
Printed Date: 22 Nov 24 at 10:25PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Inserting text behind existing text
Posted By: BobW
Subject: Inserting text behind existing text
Date Posted: 18 Mar 13 at 9:17PM
I would like to open a PDF and add text to it.  I would like the text I add to be behind any existing text or graphics on the page.  I can't quite figure out how to do this!

Thanks,

Bob



Replies:
Posted By: Ingo
Date Posted: 18 Mar 13 at 10:18PM
Hi Bob!

QP offers extract functionalities. Please read here:
http://www.debenu.com/docs/pdf_library_reference/Extraction.php
There are options to extract with string positions included.
So you can determine where's the text content on each pages.
Additionally QP tells you the complete page dimensions and with
GetOrigin tells you where to begin and SetMeasurementUnits you
can tell QP about the units you wanna use.
So you can calculate the region which should be still clear.
Now you can use the drawing functionalities for your own text.

Cheers, Ingo




Posted By: BobW
Date Posted: 19 Mar 13 at 4:05PM
I'm familiar with the extract functions and I use them in other applications.  For the job I am working on now, I need to place additional text in the PDF and make it look as if the text that is already there was printed on top of if. This is for artistic reasons.  Is there a way to do this?


Posted By: Ingo
Date Posted: 19 Mar 13 at 5:01PM
So you need the position- and font-values from the extract-functions (chose the right options).
Calculate a little bit with these values and draw onto the existing content.
 


Posted By: AndrewC
Date Posted: 21 Mar 13 at 8:05AM
Bob,

You could try something along the lines of the following

   QP.LoadFromFile (...
   QP.SelectPage(1);
   int cs = NewContentStream();

   QP.SetOrigin(1);
   QP.AddStandardFont(4);
   QP.SetTextSize(30);
   QP.DrawText(20,20, "Hello World");

   QP.MoveContentStream(cs, 1);

   QP.SaveToFile("newfile.pdf");

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.


Andrew


Posted By: BobW
Date Posted: 22 Mar 13 at 3:02PM
Andrew,

That does the trick!  Thanks so much!

Bob



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk