ShowTextBlock returns unexpected values for pTextBounds

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 returns unexpected values for pTextBounds

Post by whoit »

I have some C# code which uses ShowTextBlock to first calculate the size of a TextBlock and then place it on a page.

I am using the exact same properties, including the same text, except that I change the input pRect and pClip boundaries slightly.
In one case the returned width is less than the input width (ok), but in another case the returned width is greater than the input width (not ok).

When the returned width is less, the text wraps and produces 5 lines.
When the returned width is greater, the text wraps differently producing 6 lines.

The issue is that the returned height is the same for both text blocks - even though one has 5 lines and the other has 6.
The value returned for 6 lines is correct while the returned value for 5 lines should be less.
textblockreturn1.png
textblockreturn1.png (14.12 KiB) Viewed 4606 times
textblockreturn2.png
textblockreturn2.png (15.08 KiB) Viewed 4606 times
Here's some code info:

Code: Select all

IPXC_CharFormat pCharFmt = null;
IPXC_ParaFormat pParaFmt = null;
IPXC_DrawTextCallbacks pCallbacks = null;
PXC_Rect pRect;
PXC_Rect pTextBounds; //will hold returned size of textblock
uint nFlags = (uint)PXC_DrawTextFlags.DTF_RichText  | (uint)PXC_DrawTextFlags.DTF_CalcSizeOnly;
string curText = "<body><p style=\"font-family:'Arial'; font-size:12pt; line-height:normal;\"><span style=\"color:#0000ff\">This is html formatted text wrapped with one word in <b>bold</b>.<br/>and a line break plus <i>italic</i> word.</span></p></body>"

//These pRect values return 6 lines and height of 80.42 - Correct
// Also, the returned width = 97.38
pRect.left = 0
pRect.top = 0
pRect.right = 110
pRect.bottom = -5000

//These pRect values return 5 lines and height of 80.42 - Incorrect
// Also, the returned width = 114.06 which is greater than the input width
pRect.left = 0
pRect.top = 0
pRect.right = 111
pRect.bottom = -5000

tmpCreator.ShowTextBlock(curText, pRect, pRect, nFlags, -1, pCharFmt, pParaFmt, pCallbacks, out pTextBounds);
How can I fix this?

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

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by Sasha - Tracker Dev Team »

Hello Wayne,

Can you please prepare a small working project that I can give to a developer for debugging this behavior?

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 returns unexpected values for pTextBounds

Post by whoit »

Hi -

I'll see what I can do but I'd appreciate it if you'd look into the code samples I already posted.

Thanks.
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by whoit »

OK, I've created and emailed a sample project and a sample PDF that illustrates the problem.

I've also added a bunch of notes in the code - look for lots of *****

Thanks.
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by TrackerSupp-Daniel »

Thank you Whoit,
Ive passed the files along to Sasha.
Regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
whoit
User
Posts: 269
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by whoit »

I know it's only been a few days, but could you give me a status update?

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

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by Sasha - Tracker Dev Team »

Hello Whoit,

Well you were doing the

Code: Select all

Math.Ceiling
Thus the incorrect behavior.

Here's the result when I commented all of the Ceiling methods:
Capture43.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 returns unexpected values for pTextBounds

Post by whoit »

Ok, well that's embarrassing.... :roll:

I'll keep testing but thanks for pointing that out.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by Sasha - Tracker Dev Team »

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