Page 1 of 1

IPXC_ContentCreator.ShowTextBlock crash

Posted: Thu Jan 25, 2018 7:46 pm
by mmasood
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

Re: IPXC_ContentCreator.ShowTextBlock crash

Posted: Fri Jan 26, 2018 8:16 am
by Sasha - Tracker Dev Team
Hello mmasood,

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

Cheers,
Alex

Re: IPXC_ContentCreator.ShowTextBlock crash

Posted: Fri Jan 26, 2018 2:55 pm
by whoit
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

Re: IPXC_ContentCreator.ShowTextBlock crash

Posted: Fri Jan 26, 2018 2:59 pm
by Sasha - Tracker Dev Team
Hello Wayne,

I'm referring to this one:
to html encoding, such as "&" becomes "&"
Cheers,
Alex

Re: IPXC_ContentCreator.ShowTextBlock crash

Posted: Fri Jan 26, 2018 5:09 pm
by whoit
I was afraid of that!

Got any tips on parsing the text for special characters?

Re: IPXC_ContentCreator.ShowTextBlock crash

Posted: Sat Jan 27, 2018 6:31 am
by Sasha - Tracker Dev Team
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