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, Sean - Tracker, Chris - Tracker Supp, 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: 271
Joined: Tue Jul 07, 2015 3:30 pm

ShowTextBlock returns unexpected values for pTextBounds

Post by whoit » Wed Jun 27, 2018 6:00 pm

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 1934 times
textblockreturn2.png
textblockreturn2.png (15.08 KiB) Viewed 1934 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.

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

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by Sasha - Tracker Dev Team » Thu Jun 28, 2018 5:48 am

Hello Wayne,

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

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

Post by whoit » Thu Jun 28, 2018 1:52 pm

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: 271
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by whoit » Thu Jun 28, 2018 5:08 pm

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: 2416
Joined: Wed Jan 03, 2018 6:52 pm

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by TrackerSupp-Daniel » Thu Jun 28, 2018 5:38 pm

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

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

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

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by whoit » Tue Jul 03, 2018 11:46 am

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

Thanks.

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

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by Sasha - Tracker Dev Team » Tue Jul 03, 2018 12:43 pm

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

Post by whoit » Tue Jul 03, 2018 1:33 pm

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

I'll keep testing but thanks for pointing that out.

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

Re: ShowTextBlock returns unexpected values for pTextBounds

Post by Sasha - Tracker Dev Team » Tue Jul 03, 2018 1:48 pm

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

Post Reply