Page 1 of 1

IPXC_Document PlaceWatermark trims strings?

Posted: Mon Jun 19, 2017 3:57 pm
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...

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Mon Jun 19, 2017 4:08 pm
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

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Mon Jun 19, 2017 4:29 pm
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.

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Tue Jun 20, 2017 9:38 am
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

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Tue Jun 20, 2017 12:38 pm
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?

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Tue Jun 20, 2017 12:44 pm
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

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Tue Jun 20, 2017 2:56 pm
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)))

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Wed Jun 21, 2017 9:15 am
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

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Wed Jun 21, 2017 12:36 pm
by whoit
Hi Alex -

Where can I find your sample?

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Wed Jun 21, 2017 1:15 pm
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

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Wed Jun 21, 2017 1:57 pm
by whoit
OK, I got it - I didn't realize I had to initialize the Font and Size

Re: IPXC_Document PlaceWatermark trims strings?

Posted: Wed Jun 21, 2017 1:59 pm
by Sasha - Tracker Dev Team
:)