IPXC_ContentCreator.ShowTextBlock crash

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

Moderators: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, 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
mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

IPXC_ContentCreator.ShowTextBlock crash

Post by mmasood » Thu Jan 25, 2018 7:46 pm

Hi Alex,

I am using IPXC_ContentCreator.ShowTextBlock to place text on the page. My setup is:
1. Language = C#
2. PDF Core API 7.0.323.3

Following is the code:

Code: Select all

contentCreator.ShowTextBlock(curZoneText, pRect, pRect, nFlags, nTextLen, pCharFmt, pParaFmt, pCallbacks, out pTextBounds);
and following is the xml node that I am reading:

Code: Select all

<ZoneText><![CDATA[<body><p style="font-family:'Arial'; font-size:12pt; line-height:normal;"><span style="color:#ff0000">This is html formatted text. <br/>Here is an ampersand &. <br/>Here is a greater than >. <br/>Here is a less than <.</span></p></body>]]></ZoneText>
and this is the text of the curZoneText variable:

Code: Select all

<body><p style="font-family:'Arial'; font-size:12pt; line-height:normal;"><span style="color:#ff0000">This is html formatted text. <br/>Here is an ampersand &. <br/>Here is a greater than >. <br/>Here is a less than <.</span></p></body>
With this text the call to ShowTextBlock crashes with the exception:
Message = "Exception from HRESULT: 0xC00CEE2C"

StackTrace = " at PDFXCoreAPI.IPXC_ContentCreator.ShowTextBlock(String pText, PXC_Rect& pRect, PXC_Rect& pClip, UInt32 nFlags, Int32 nTextLen, IPXC_CharFormat pCharFmt, IPXC_ParaFormat pParaFmt, IPXC_DrawTextCallbacks pCallbacks, PXC_Rect& pTextBounds)
at DS.DS.SD(Int32 iPageNumber) in C:\Projects\DS\DS\SD.cs:line 129"
If I try to Html Encode the string curZoneText then this is the string that I get:
<body><p style="font-family:'Arial'; font-size:12pt; line-height:normal;"><span style="color:#ff0000">This is html formatted text. <br/>Here is an ampersand &. <br/>Here is a greater than >. <br/>Here is a less than <.</span></p></body>
and this is the exception that I get:
Message = "Exception from HRESULT: 0xC00CEE2D"

StackTrace = " at PDFXCoreAPI.IPXC_ContentCreator.ShowTextBlock(String pText, PXC_Rect& pRect, PXC_Rect& pClip, UInt32 nFlags, Int32 nTextLen, IPXC_CharFormat pCharFmt, IPXC_ParaFormat pParaFmt, IPXC_DrawTextCallbacks pCallbacks, PXC_Rect& pTextBounds)
at DS.DS.SD(Int32 iPageNumber) in C:\Projects\DS\DS\SD.cs:line 129"
If I manually remove the 3 characters "&", "<" and ">" from the string it processes correctly.
If I manually encode the 3 characters "&", "<" and ">" in the string, it processes correctly.

Question: How do I get this to work properly?

Regards,
M

User avatar
Sasha - Tracker Dev Team
User
Posts: 4649
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_ContentCreator.ShowTextBlock crash

Post by Sasha - Tracker Dev Team » Fri Jan 26, 2018 8:16 am

Hello mmasood,

You will have to escape those characters in the strings only (not the entire xml).

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_ContentCreator.ShowTextBlock crash

Post by whoit » Fri Jan 26, 2018 2:55 pm

Hi Alex -

When you state "escape those characters", are you referring to html encoding, such as "&" becomes "&"
OR
is there another way to escape the characters in the TextBlock?

Thanks,
Wayne

User avatar
Sasha - Tracker Dev Team
User
Posts: 4649
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_ContentCreator.ShowTextBlock crash

Post by Sasha - Tracker Dev Team » Fri Jan 26, 2018 2:59 pm

Hello Wayne,

I'm referring to this one:
to html encoding, such as "&" becomes "&"
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

Re: IPXC_ContentCreator.ShowTextBlock crash

Post by whoit » Fri Jan 26, 2018 5:09 pm

I was afraid of that!

Got any tips on parsing the text for special characters?

User avatar
Sasha - Tracker Dev Team
User
Posts: 4649
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_ContentCreator.ShowTextBlock crash

Post by Sasha - Tracker Dev Team » Sat Jan 27, 2018 6:31 am

Hello Wayne,

Well just escape all of those characters (you can easily google them up) if they are not inside of any of the tags (that to can be easily done).

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply