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!
![]() |
Find and replace text within a PDF |
Post Reply ![]() |
Author | |
DanButton ![]() Beginner ![]() Joined: 19 Apr 11 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
DanButton ![]() Beginner ![]() Joined: 19 Apr 11 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() |
Thanks Werner - that's something for me to get started with - I'll give that a try!
Cheers, DB
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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 70.8661 680.315 Tm1 0 0 1 66.8661 680.315 Tm (d)Tj ETBT (a)Tj ETBT (t)Tj ET BT
1 0 0 1 78.8661 680.315 Tm (e)Tj ET |
|
![]() |
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