Text Search and Replace

This Forum is for the use of Clarion For Windows - Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Tracker - Clarion Support, John - Tracker Supp, Support Staff, moderators

Post Reply
Posts: 9
Joined: Sat Mar 22, 2008 11:00 am

Text Search and Replace

Post by jrademan » Mon Mar 24, 2008 5:49 am


Looking for a method to search for text in PDF file and then replace it
with new text.


Search for text, extract it, also getting the font,size and then replace it with new text.



John - Tracker Supp
Site Admin
Posts: 8204
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada

Post by John - Tracker Supp » Mon Mar 24, 2008 7:04 am

Hi Johan,

the only way to achieve this as described using the XCPRO35 library is to use the low level API - to do so requires that you are quite literally a 'guru' with the PDF format and is no simple task even then - we also provide no support for users using the low level API as it is way too complex and if you really know the format that well - you would not need help.

A practical way to achieve this for an average user is to either use the Viewer ActiveX to visually provide your users to locate and use the text box tool to 'cover' the desired old text and replace with new text - or use XCPRO35 to extract all text and search the provided extraction for the text required and then use the 'watermark' functionality to cover up and replace the text in a similar means to that described for the Viewer ActiveX.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support

Posts: 14
Joined: Sun Sep 24, 2006 6:02 am

Post by johanr » Tue Mar 25, 2008 6:58 am

Thanks for the reply and the info, perhaps this situation does not justify that level of effort to do a search and replace.

Another way possibly for me would be to do a search for a string and get the
position, font, size, then I could create a new PDF using textout with my new text.

Are there any search functions that will provide info on if the text is found and where it was found, and perhaps what font and size was used.
The most important would be the position.



Lzcat - Tracker Supp
Site Admin
Posts: 719
Joined: Thu Jun 28, 2007 8:42 am

Post by Lzcat - Tracker Supp » Tue Mar 25, 2008 8:49 am

There are no functions for text search in xcpro35/xcpro40, however there are functions to get text with positions, colors, font sizes and names.
But note that:
1. Not all PDF files contains text which can be extracted.
2. Text in PDF file may have different order than visible, so you will need some heuristic algorithm to compose it to 'natural' order.
3. Text in PDF may not contain spaces or contain extra spaces, but look ok, so you will need handle this somehow.
To get text from PDF you should use PXCp_ET_??? functions. Good sample of their usage is in help to function PXCp_ET_AnalyzePageContent (C++).
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

Posts: 14
Joined: Sun Sep 24, 2006 6:02 am

Post by johanr » Tue Mar 25, 2008 10:10 am

Hi Victor

The PDF file in question would be one that I would have created.
I am using MsWORD to create a template file, it's easy to design it like this or to make changes. From the Word file I would print to PDF file and then have a template that I can use to insert data into.
I like this as the data would be inserted very accurately and quickly.
The report has about 12 blocks/tables with 12 rows in each table coming from different data files.

Then at runtime (in clarion) I would search for the 'data placeholders' and then replace them with data using TextOut.

If I cant replace text the idea would be to use one file as a template and another as the design template.

Do you have any clarion example code that would return text postion in a pdf file along with font and size.
There would only be one occurance of the text in the file as I would be the one creating the file. eg. Table1Row1, Table1Row2 etc..



Post Reply

Return to “PDF-Tools SDK (DLL Libraries Only) - Clarion For Windows Developers Only Please”