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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Find and replace text within a PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Find and replace text within a PDF

 Post Reply Post Reply
Author
Message
DanButton View Drop Down
Beginner
Beginner


Joined: 19 Apr 11
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote DanButton Quote  Post ReplyReply Direct Link To This Post Topic: Find and replace text within a PDF
    Posted: 17 Feb 12 at 4:48PM
Hi,

Just wondering if there's a handy way to find and replace text within a PDF.

Scenario:
We have a PDF with text placement tags in it (note, this is not a PDF Form with fields as such), such as:
==========
Date <date>
Dear <firstname>, this is a PDF with some wonderful stuff on it.
==========

Having find and replace would allow us to search for <date> and replace it programmatically with today's date. Likewise with the <firstname> text area. However, the <firstname> bit could possibly present a problem as the length of the firstname may influence the placement of the text following it.

Anyone done anything like this before with QuickPDF without using a PDF form? Any planned functionality?

Any tips would be great.

Thanks

DB
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 17 Feb 12 at 9:09PM
Hi,

here a short idea. The problem seems to be the replace part.

The bad part of my solution idea: you have to search alone in a object-content. It is to get over QP.GetObjectToString. It is nothing for people without a little understanding of PDF-operators. You would have to look for textoutputoperation and to find there your keys like <date>. The problem is, that it must not be a single string. It looks other (I show the most simple case):

BT
1 0 0 1 70.8661 680.315 Tm
(<date>)Tj
ET


But if there is letterspacing used, it looks more complicated.

Let's assume you find this. Then you may replace (look into the PDF-spec. to be sytactically correct) it by your wished string.

The good part is small: After this you give the modified objectcontent easy via QP.SetObjectFromString back to QPL.

The documentation says "This is for advanced use only."

There is some work for you.


Cheers,
Werner
Back to Top
DanButton View Drop Down
Beginner
Beginner


Joined: 19 Apr 11
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote DanButton Quote  Post ReplyReply Direct Link To This Post Posted: 20 Feb 12 at 9:14AM
Thanks Werner - that's something for me to get started with - I'll give that a try!

Cheers,

DB
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 22 Feb 12 at 2:55PM
QPL currently doesn't support the replacing of text in a PDF file.

It is not always easy to implement such a function as there are many ways to draw the same text in a PDF file

1.

BT
1 0 0 1 70.8661 680.315 Tm
(<date>)Tj
ET

2.

BT
1 0 0 1 70.8661 680.315 Tm
(da)-10.0(te)Tj
ET

3. 

BT
1 0 0 1 66.8661 680.315 Tm
(d)Tj
ETBT
1 0 0 1 70.8661 680.315 Tm
(a)Tj
ETBT
1 0 0 1 74.8661 680.315 Tm
(t)Tj
ET
BT
1 0 0 1 78.8661 680.315 Tm
(e)Tj
ET
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store