IPXC_Document PlaceWatermark trims strings?

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

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, 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
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

IPXC_Document PlaceWatermark trims strings?

Post by whoit »

Hi -
I'm using IPXC_Document PlaceWatermark and it seems that it is inherently trimming (removing) spaces from the beginning and the end of my strings.
So " hello " becomes "hello".

How can I avoid this?

It is wreaking havoc with my formatting...
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: IPXC_Document PlaceWatermark trims strings?

Post by Tracker Supp-Stefan »

Hello whoit,

Why do you need those spaces in the first place?
Have you tried using the horizontal and vertical offset parameters instead:
https://sdkhelp.pdf-xchange.com/vie ... markParams

Also - try adding e.g. non breakable spaces - and see if those are removed from the start and end of your string.

A sample illustrating how exactly you are trying to use the code might also help our devs to check why you are getting the unexpected result you get - so please do consider providing that as well (make sure no licensing info is visible).

Regards,
Stefan
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_Document PlaceWatermark trims strings?

Post by whoit »

Hi -
I simply need the spaces because they are there - meaning, if a client wants them for spacing purposes, I need to keep them.
I suggest that you should not be trimming text without offering a way to turn it off since we can easily trim strings on our own.

What is a non-breaking space when using PlaceWatermark?
(I know what one is for HTML, but how would I add one here?)
EDIT: I tried a non-breaking space (ascii 255) but it printed out as a visible character so this will not work.

As a basic example (without code) - I have a string in which I allow embedded html tags like "<b></b>"
So I process a string: "This is a <b>bold</b> example."
In order for me to print this correctly onto a pdf, I have to perform three PlaceWatermark calls after I parse the string:
1) "This is a " (note the space)
2) "bold" (where the WatermarkParams indicate bold=true and I calculate the new x position based on the width of the previous string)
3) " example." (again, note the space and I calculate the new x position based on the width of the previous string)

If there is a better way to do this, please let me know.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document PlaceWatermark trims strings?

Post by Sasha - Tracker Dev Team »

Hello whoit,

You can calculate the width of the space and shift your x position to that value.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_Document PlaceWatermark trims strings?

Post by whoit »

Hi Alex -

Yes, that is what I am already doing.
The problem is that the width calculation is not very accurate (I'm using VB)

Is there a "text width" function within the Tracker library?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document PlaceWatermark trims strings?

Post by Sasha - Tracker Dev Team »

Hello whoit,

Check this post - it holds the method you need:
https://forum.pdf-xchange.com/ ... ze#p102547

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_Document PlaceWatermark trims strings?

Post by whoit »

Hi Alex -

I looked into that thread and I am having the same issue the other poster had - I am unable to execute the CalcTextSize without the same error.

My Code:
Dim myCreator As IPXC_ContentCreator
Dim xWid As Double
Dim xHit As Double

Set myCreator = pDoc.CreateContentCreator '''pDoc is an IPXC_Document
myCreator.CalcTextSize 12, "hello", xWid, xHit, Len("Hello")

His Code:
I did find this method which seems should be what I want, but everytime it throws an error 5, invalid procedure call or argument, note HRESULT is not available in vb6
Dim RectWidth As Double
Dim RectHeight As Double
Dim FS As Double
FS = 6
Dim CC As PDFXEditCtl.IPXC_ContentCreator
Set CC = Me.PDF.Doc.CoreDoc.CreateContentCreator
Call CC.CalcTextSize(FS, UserName & " DigSign " & CStr(Now), RectWidth, RectHeight, Len(UserName & " DigSign " & CStr(Now)))
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document PlaceWatermark trims strings?

Post by Sasha - Tracker Dev Team »

Hello whoit,

Please look at my sample and add the required initialization methods to the Content Creator before calling the CalcTextSize method.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_Document PlaceWatermark trims strings?

Post by whoit »

Hi Alex -

Where can I find your sample?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document PlaceWatermark trims strings?

Post by Sasha - Tracker Dev Team »

Sasha - Tracker Dev Team wrote:Hello whoit,

Check this post - it holds the method you need:
https://forum.pdf-xchange.com/ ... ze#p102547

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_Document PlaceWatermark trims strings?

Post by whoit »

OK, I got it - I didn't realize I had to initialize the Font and Size
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document PlaceWatermark trims strings?

Post by Sasha - Tracker Dev Team »

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