Add Text when modifying an existing PDF file

This Forum is for the use of 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 or PDF-XChange Viewer SDK if appropriate.

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

Post Reply
mmasood
User
Posts: 101
Joined: Fri Sep 18, 2015 9:49 pm

Add Text when modifying an existing PDF file

Post by mmasood »

Hi,

I am trying to add stamps (text) and watermarking to an existing PDF file. I can add watermarks by using the function PXCp_AddWatermark but when I trying to add the text to the PDF file using the function PXC_TextOutA the program crashes. What I have found out so far is that I cannot use PXC_TextOutA function with an existing PDF file. I am using VB6.

I am using the PDF-XChange 5 SDK PRO. I looked at the samples provided with the SDK and in there I found the function PXC_TextOutA being used but with a new PDF file. The sample that I looked at is "Examples\SDKExamples\VBExamples\PDFXCDemo".

Below is a link that my colleague posted 9 years ago and in there Ivan mentions "Yes, for now XCPRO35 doesn't support such type of modification of an existing PDF. Our upgrade to the SDK later this year, will merge all our library functions into a single library and allow their use when working with new or existing PDF pages/files - creation, manipulation, etc."

https://forum.pdf-xchange.com/ ... 76&p=12826

Following are my questions:

1. Can I use PXC_TextOutA function to add stamps to existing PDF files?
2. Is there a better way to achieve the stamping functionality?

Thanks
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add Text when modifying an existing PDF file

Post by Tracker Supp-Stefan »

Hello mmasood,

Is there any particular reason you are using the PXC_TextOutA and not e.g. the PXC_TextOutW (Unicode) alternative?

The below is taken from the description page of the PXC_TextOutA method:

Code: Select all

Comments

Function PXC_TextOutA outputs the string without taking into the consideration its length and will carry-over additional content to the next line. To output longer strings and/or strings with hyphens, the PXC_DrawTextExW function should be used.

Remarks

Strings generated using this function must be ANSI strings. To output strings, which cannot be converted to ANSI, the PXC_TextOutW function should be used.
So please do try the unicode method and see if it works better for you.

Regards,
Stefan
mmasood
User
Posts: 101
Joined: Fri Sep 18, 2015 9:49 pm

Re: Add Text when modifying an existing PDF file

Post by mmasood »

Hi Stefan,

The issue is what value I pass in as the content? In the examples, it is passing in the newly created page.

This is what the PXC_TextOutA declaration looks like:

HRESULT PXC_TextOutA(
_PXCContent* content,
LPCPXC_PointF origin,
LPCSTR lpszText,
LONG cbLen
);

In the example, the following line is used to get the page which in turn is passed to PXC_TextOutA function:

PXC_AddPage(pdf, PW, PH, page)

and i am using this in my code because I want to get an existing page:

PXC_GetPage(pdf, 0, page)

and this line causes the crash.

Am I using it wrongly? What should I use to get the "content" parameter that I can pass to the PXC_TextOutA or PXC_TextOutW function?

Thanks,
M
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add Text when modifying an existing PDF file

Post by Tracker Supp-Stefan »

Hello M,

Actually one of our devs just reminded me something I should have seen myself yesterday - you are trying to mix PXC_ and PXCp_ methods. the first ones are mostly designed to be used when building up new files from scratch and the second are for manipulating existing files. You can not use them both at the same time.
You need to create your file (Using PXC_ methods) , save it and then use the PXCp_ ones for further manipulation.

In any case - the PDF Tools SDK is quite old now, and is unlikely it will get any new updates, as it is replaced by the Core API SDK. We would strongly recommend you to consider switching to the Core API:
https://www.pdf-xchange.com/product/pd ... re-api-sdk

Regards,
Stefan
mmasood
User
Posts: 101
Joined: Fri Sep 18, 2015 9:49 pm

Re: Add Text when modifying an existing PDF file

Post by mmasood »

Hi Stefan,

I am using VB6. I am using the PDF-XChange 5 SDK PRO. Here is what I want to do:

1. Open an exisitng PDF file.
2. Add watermark to it.
3. Add text around the edges of the document.

I am able to achieve 1 and 2 right now. What functions should I be using to achieve 3? Is there any sample that is shipped with the installer that I can look into?

You mentioned about Core API SDK. Which one, if any, of the PXC_ or PXCp_ are the Core API functions? Can you provide some sample code that I can look into for the Core API? How can I achieve all three of the above using Core API?

Thanks,
M
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add Text when modifying an existing PDF file

Post by Tracker Supp-Stefan »

Hello mmasood,

You can achieve 3 by adding text based watermark ;) and you can add more than one to a file.

There are sample projects included with each of our SDK package downloads (including the Core API).
The Core API uses different names for it's methods and interfaces - but you should be able to do with it anything that you needed the separate PXC_ and PXCp_ libraries until now with just one package.

Regards,
Stefan
mmasood
User
Posts: 101
Joined: Fri Sep 18, 2015 9:49 pm

Re: Add Text when modifying an existing PDF file

Post by mmasood »

Hi Stefan,

1. What libraries/dll's do I need to add to my VB6 project to access the Core API functions (IPXC_)?
2. Do you have sample VB6 application using those libraries?

Thanks,
M
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Add Text when modifying an existing PDF file

Post by Sasha - Tracker Dev Team »

Hello mmasood,

Do read this https://sdkhelp.pdf-xchange.com/view/Main_Page
As for the samples - we do have a sample project FullDemo on our Editor SDK written in C# - you can experiment with Core API functions there.

HTH
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply