Print Page | Close Window

Replacing text in existing PDF

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=2956
Printed Date: 15 May 25 at 8:11AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Replacing text in existing PDF
Posted By: amberwine
Subject: Replacing text in existing PDF
Date Posted: 14 Aug 14 at 9:04AM
I need to replace a small amount of text in an existing PDF file. Ideally, I'd like to use the existing file as a 'template', by:

1. loading it
2. making a copy for output
3. searching the copy for the text to replace
4. replacing the text with new text
5. saving the modified copy

The text is currently of the form "<TXT1>" and is to be replaced with a something like "V1234", though the number can vary. I need to produce lots of copies of the original PDF, saving each with a different filename and replacement text.

I do have some control over the format of the source PDF, so if modifying the original PDF might make this job easier, please feel free to make suggestions.

Can you suggest Debenu QL functions that might help me to:

1. Locate the text in the PDF
2. Replace it with the new text

Alternatively, if you point me to some appropriate sample code, that would be great.

Many thanks for your help.



Replies:
Posted By: Wheeley
Date Posted: 14 Aug 14 at 8:31PM
You had better do a forum search about this. It has been answered before. Short answer, it will be extremely difficult because of how PDFs are put together. Not because of the tool you use.

Wheeley


Posted By: AndrewC
Date Posted: 15 Aug 14 at 9:57AM
Amberwine,

A PDF file is a binary format and can also include compressed data.  So it is not easily possibly to replace text unless the text is the same length as the text you are replacing.

  QP.ReplaceTag is designed specifically for this.

To get access to the drawing commands you will need to work with the ContentStream functions.

http://www.debenu.com/docs/pdf_library_reference/PageManipulation.php.  Most of the required functions can be found here.

Andrew.




Posted By: AndyD
Date Posted: 18 Aug 14 at 9:02AM
Alternativey if you have the full version of Acrobat, you could replace the default <txt> locations with form fields and then with QuickPDF you can call and fill these fields as you need. That is the way I have done it to produce filled letters, technical documents etc from within an app.
 
Andy



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