VB Code to Find/Replace text in a PDF

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
drtn
User
Posts: 1
Joined: Wed Mar 25, 2020 9:07 am

VB Code to Find/Replace text in a PDF

Post by drtn » Wed Mar 25, 2020 9:59 am

001-OPE-ZZ-ZZ-DR-Y-0002.pdf
(17.76 KiB) Downloaded 1 time
vb code.zip
(942 Bytes) Not downloaded yet
The following is the steps one of your colleagues suggested I should take to achieve my goal of find/replace text in a PDF.

What I suggest is:
1) Download the CoreAPI application and see the samples presented there (especially content ones) as the CoreAPI is the inside part of the EditorSDK
2) Download the FullDemo application and try adding menu items (plenty info on forums for those tasks) and try using content operations - for adding and removing it.
3) The easiest way of doing that task would be:
a) Finding the text on the Core level
b) Finding the content items that hold all of that text
c) Saving the coordinates and style of that text
d) Remove that text entirely
e) Add new text

The attached zipped vb code, I believe gets me as far as step c)? Unfortunately, on running the following line of code, I get the attached error messsage.
image.png


Set res = objContent.Items.Item(i).Text_SetDataSA(retv2, ts)

Now it may be a limitation of VB or that I have completely misunderstood how to replace text and the code is nonsense!

Some guidance would be very much appreciated.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4709
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: VB Code to Find/Replace text in a PDF

Post by Sasha - Tracker Dev Team » Thu Mar 26, 2020 1:45 pm

Hello drtn,

Here's a C# sample that I have on the method that also uses Safe Array (SA):

Code: Select all

IPXC_ContentItem item = content.Items[i];
if (item.Type != PXC_CIType.CIT_Path)
	continue;
Array aCmds, aPts;
item.Path_GetDataSA(out aCmds, out aPts);
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply