Print Page | Close Window

Fix a wrong 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=843
Printed Date: 12 May 24 at 12:42PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Fix a wrong PDF
Posted By: jabaltie
Subject: Fix a wrong PDF
Date Posted: 24 Oct 07 at 8:12AM
Hello !

I used QuickPDF to load a PDF  template and stuff field contents into it, generating a new PDF file (LoadFromFile, SetFormFieldValue , FlattenFormField and then SaveToFile).

So far , so good.

It happens that the PDF template was WRONG.

Now I need to modify those generated PDFs, in order to replace a very small string.

IOW, I need to replace ".DES." by ".PRO."  .

I tried to load the PDF into my editor, in binary mode and to replace the strings directly cause the editor allows a kind of binary or "raw" editing. It doesnt work.

What could I do ?

You can have a sample of the PDF here :

http://www.DES.online.unimep.br/au/pub/wrong.pdf

I thought about doing a very simple VBScript to modify it but, dont know how to start....

Thanks in advance 4 your help !







Replies:
Posted By: chicks
Date Posted: 26 Oct 07 at 6:01PM
When you edit anything in a PDF, you will most likely mess up the XREF table. Reader will try to fix the errors, but might not be able to.

You can use pdftk to do some simple edits. It has the capability of fixing corrupt XREFs when it saves. You'll need to have it uncompress streams in order to edit compressed text:

1. Uncompress wrong.pdf, save as wrong1.pdf
$ pdftk wrong.pdf output wrong1.pdf uncompress

2. Edit wrong1.pdf, make your changes
$ vi wrong1.pdf

3. Recompress and fix wrong1.pdf, save as right.pdf
$ pdftk wrong1.pdf output right.pdf compress

(I did this in a *nix environment, it will also work fine with Windows, so long as you use a binary editor).



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