Page 1 of 1

ShowTextBlock strips out spaces in strings

Posted: Mon Jan 07, 2019 5:30 pm
by whoit
Hi -

We've got a big problem with ShowTextBlock stripping out spaces from within strings.

For example, if I use the string "Hello Goodbye",
(Hello separated with multiple spaces - doesn't even show up in this Forum!!!!)

it shows up on my document as: "Hello Goodbye".

This a real issue for our clients.

We're using: PDF Core Version: x86 7.0.326.0

Please tell me that there is a fix for this.....

Thanks.

Re: ShowTextBlock strips out spaces in strings

Posted: Tue Jan 08, 2019 7:02 am
by Sasha - Tracker Dev Team
Hello Wayne,

Please open the CoreAPIDemo application's sample number "1.4 Add text to the center of the first page" (the AddTextToThePageCenter method) and try adding spaces to the "Centered Text" string - from what I see, everything worked as it should.

Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Tue Jan 08, 2019 1:44 pm
by whoit
Hi Alex -

I tried your sample, but you are only using plain text.

I am using RichText
(uint)PXC_DrawTextFlags.DTF_RichText;

(Sorry I didn't mention that in the first post)

Re: ShowTextBlock strips out spaces in strings

Posted: Wed Jan 09, 2019 8:16 am
by Sasha - Tracker Dev Team
Hello Wayne,

Thought so. Well, this is a correct behavior of the XFA format - to preserve spaces, you will have to use the the "xfa-spacerun:yes" style, as described here:
http://www.verydoc.com/documents/pdf-xfa/pg_0949.htm

Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Wed Jan 09, 2019 1:53 pm
by whoit
Hi Alex -

That fixes the issue - thanks!

One minor additional question though - your reply pointed me to the
XFA Doc v 2.4 - is that the correct version to reference?

I have a PDF with v3.3 from 2012....

Thanks Again,
Wayne

Re: ShowTextBlock strips out spaces in strings

Posted: Wed Jan 09, 2019 2:03 pm
by Sasha - Tracker Dev Team
Hello Wayne,

The newer the better.

Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Wed Jan 09, 2019 2:10 pm
by whoit
OK, thanks.

Re: ShowTextBlock strips out spaces in strings

Posted: Fri Jan 11, 2019 1:01 pm
by Sasha - Tracker Dev Team
:)

Re: ShowTextBlock strips out spaces in strings

Posted: Fri Feb 01, 2019 3:10 pm
by whoit
Hi Again -

After delivering this fix to a customer, they pointed out to us that while the text added with ShowTextblock
while using "xfa-spacerun:yes" looks ok on the PDF,
when you actually copy/paste to a text file there is only a single space.
In fact you don't need to copy/paste from the PDF, you can simply try
moving your cursor between characters with the arrow keys to count.

For example, if the text is:

Hello goodbye (5 spaces)

but after applying to the PDF then testing, it is actually:
Hello goodbye (1 space)

This is causing grief for our clients as they require that 5 actual spaces are in the resulting text.
We need to be able to use the RichText option and still retain the actual spaces/count.

Re: ShowTextBlock strips out spaces in strings

Posted: Fri Feb 01, 2019 3:22 pm
by Sasha - Tracker Dev Team
Hello Wayne,

Can you give us a pdf sample and also a code snippet that you have used to generate the xfa?

Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Fri Feb 01, 2019 3:33 pm
by whoit
Hi Alex -

I can't provide a sample as our code is way too complex.

However you can simply replicate this using the Richtext setting in Showtextblock,
then using this text (you will need to put 5 spaces between Hello and gooodbye as the Forum removes them too):

<body><p><span style="xfa-spacerun:yes">Hello goodbye</span></p></body>

EDIT:
I've read some documentation on XFA which states that "xfa-spacerun" only provides a visual approximation of the spaces, and not the actual spaces. So this solution will not work for our client and we need another option.

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 04, 2019 8:24 am
by Sasha - Tracker Dev Team
Hello Wayne,

Try using this option and then copy/paste the text:
image.png
Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 04, 2019 1:34 pm
by whoit
Hi Alex -

We use the Core API, not the Editor.

What does this method do anyway?
By the description it looks like it's simply using Justification (which is not what we want).

Is there an equivalent Method in the API ?

-Wayne

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 04, 2019 3:08 pm
by Sasha - Tracker Dev Team
Hello Wayne,

From what you said, your client uses copy/paste from the PDF. If he uses the End-User Editor, then he can turn on this option so that the spaces would be preserved.

Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 04, 2019 3:16 pm
by whoit
Hi Alex -

Our clients do not necessarily use your editor, so that option is not available to us or to them.

They will most likely use Acrobat Reader to copy the text we add to the PDF.

Either way, I really need a solution that creates actual spaces, and not just the appearance of spaces.
This way, it will not matter what PDF viewer is used.

Thanks,
Wayne

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 11, 2019 9:15 am
by Sasha - Tracker Dev Team
Hello Wayne,

This is a document generated by the Acrobat Livecycle Designer:
FiveSpaces_.pdf
(15.55 KiB) Downloaded 33 times
There are two blocks of text - one generated from your XFA, another - the 5 spaces were manually put there so that the designer generates it for itself.
Both of them are showing one space when copying from Acrobat and 5 spaces when copying from the Editor. Also, there are 5 physical spaces in the content of the page.
When you are using "Copy With Formatting" in the Acrobat - it will copy that text with 5 spaces.
The same behavior would be if you are generating the file with our SDK from the same XFA string.
Different Editors/Readers will behave differently with Copy operations - they decide how to handle consecutive spaces by themselves.

Cheers,
Alex

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 11, 2019 1:39 pm
by whoit
Hi Alex -

Ok, thanks for that information - I'll be sure to tell clients to use 'copy with formatting' to resolve the issue.

:)

-Wayne

Re: ShowTextBlock strips out spaces in strings

Posted: Mon Feb 11, 2019 1:43 pm
by Sasha - Tracker Dev Team
:)