ShowTextBlock strips out spaces in 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

ShowTextBlock strips out spaces in strings

Post 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.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock strips out spaces in strings

Post 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)
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock strips out spaces in strings

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post by Sasha - Tracker Dev Team »

Hello Wayne,

The newer the better.

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

Re: ShowTextBlock strips out spaces in strings

Post by whoit »

OK, thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post by Sasha - Tracker Dev Team »

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

Re: ShowTextBlock strips out spaces in strings

Post 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.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock strips out spaces in strings

Post 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.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post by Sasha - Tracker Dev Team »

Hello Wayne,

Try using this option and then copy/paste the text:
image.png
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock strips out spaces in strings

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock strips out spaces in strings

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post by Sasha - Tracker Dev Team »

Hello Wayne,

This is a document generated by the Acrobat Livecycle Designer:
FiveSpaces_.pdf
(15.55 KiB) Downloaded 177 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
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock strips out spaces in strings

Post 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
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock strips out spaces in strings

Post by Sasha - Tracker Dev Team »

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