PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

Moderators: Tracker Support, Chris - Tracker Supp, Vasyl-Tracker Dev Team, 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.
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

ShowTextBlock positioning using returned Height and Width

Wed Nov 08, 2017 6:28 pm

I'm having issues when trying to Rotate and Position a TextBlock.
Specifically, the height of the textblock returned from ShowTextBlock seems to be incorrect.

For example, if I position a TextBlock at 0,0 (lower left of page),
then rotate it 90 degrees (counterclockwise)
I would expect the top edge of my text to be placed exactly on the left edge of my page.
However, it is always inside the edge (to the right of the page edge) like this:

Image

This is how I'm using ShowTextBlock (pertinent code shown):
// Set the rect at 0,0
PXC_Rect pRect;
pRect.top = 0;
pRect.left = 0;
pRect.bottom = -100;
pRect.right = pageWidth;

nFlags = (uint)PXC_DrawTextFlags.DTF_RichText;
//turn on CalcSizeOnly
nFlags = nFlags | (uint)PXC_DrawTextFlags.DTF_CalcSizeOnly;
contentCreator.ShowTextBlock(...);
contentCreator.RotateCS(90.0);
contentCreator.TranslateCS(0,0);

//turn off CalcSizeOnly
nFlags = nFlags ^ (uint)PXC_DrawTextFlags.DTF_CalcSizeOnly;
contentCreator.ShowTextBlock(...);


As you can see, the gap increases with the font size.
How can I position the TextBlock to meet he page edge regardless of the font size?


Note also that when I place a TextBlock at the bottom of my page and move it up by the height
(returnedRect.top - returnedRect.bottom)
it is not enough. The returned values for the text height do not seem to be accurate. Notice that
the descender of the "p" in "plus" is cut off, as are parts of all text on the bottom line.
Image
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2610
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock positioning using returned Height and Width

Thu Nov 09, 2017 7:56 am

Hello Wayne,

Here's the specification about fonts:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd145122(v=vs.85).aspx
https://developer.apple.com/library/con ... dling.html
You have two metrics available here (by using show text block) you will have line gap + descend as a bottom and line height as top.
If you are using ShowTextLine method then the nY and nX values can be either one of the two mentioned above or baseline (as mentioned in the http://sdkhelp.tracker-software.com/vie ... tLineFlags).

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock positioning using returned Height and Width

Thu Nov 09, 2017 1:24 pm

Hi Alex -

I am well versed in digital fonts, and I understand the mechanics of them and in fact taught college design and layout
courses for 10 years (you of course couldn't know that). I know digital font specs very well.

One of the things I have already tested in an attempt to remove the top space above the "T" is to eliminate the line height.
I've set it to 0, and even tried negative values -fontsize and it still remains.

Basically my question is simple - given the font metrics, why isn't the value returned from ShowTextBlock for height accurate?
Shouldn't the value include the ascender, descender, and line-height portions?

1) So could you could please show me a sample of how you use line-height to remove or account for this space above the "T"?

2) Regarding the descenders - I'm not sure how the specs account for the math in my second issue
(where the descender of the "p" is cut off). When the ShowTextBlock method returns the final block height, the value
is too small. I cannot position my block properly if the returned height is incorrect.
Could you please show me a sample of how you would position this to account for descenders/line-height?

Please keep in mind that my font Family, Size, Style, and Weight are all variable...
And sample code in any language is fine.

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

Re: ShowTextBlock positioning using returned Height and Width

Thu Nov 09, 2017 1:56 pm

Hello Wayne,

We position by ascent as it should be and it is not being regulated by line gap in any cases. If the text position is top (TextBlock) then we offset by the ascent of the biggest character in the block.
The Ascent itself is not the CapHeight and the Cap height itself is not the height of the letter T and is Font relative.
Image

Could you please show me a sample of how you would position this to account for descenders/line-height?

1) You can output text in the BaseLine position by using ShowTextLine method and all of the Cap Height calculation (or what you want) should be done from your side.

2) Are you sure that the height of the overall text in the block does not exceed 100? Give us a small working sample that we can launch and see the behavior.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock positioning using returned Height and Width

Thu Nov 09, 2017 4:01 pm

Hi Alex -

Can you give me an email address to send the sample code?
(It has our key embedded)

Thanks,
Wayne
 
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 11659
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: ShowTextBlock positioning using returned Height and Width

Thu Nov 09, 2017 5:11 pm

Hi Wayne,

You can send the project to support@tracker-software.com with a note in the e-mail body that it should be forwarded to Alex, and we will pass it along.

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

Re: ShowTextBlock positioning using returned Height and Width

Fri Nov 10, 2017 10:04 am

Hello Wayne,

The bottom text was not cut of (aside from the line-height problem):
Image

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock positioning using returned Height and Width

Fri Nov 10, 2017 2:08 pm

Hi Alex -

I ran more tests yesterday and figured out what the problem is - if part of the HTML/CSS
is not interpreted properly (line-height, or font-name, etc) then the returned height value is incorrect.

If it worked for you, you can replicate the problem by using a font-name (or font-family) that will fail.
In that case a default font is used but the height measurement will be wrong.
Try
style="font-size:18; font-name:'Alex'"

and see what happens....
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2610
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock positioning using returned Height and Width

Mon Nov 13, 2017 8:44 am

Hello Wayne,

This works correctly:
string curZoneText = "<p><span style=\"font-name:'Alex';font-size:18pt;color:#ff0000\">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>";


I ran more tests yesterday and figured out what the problem is - if part of the HTML/CSS
is not interpreted properly (line-height, or font-name, etc) then the returned height value is incorrect.

Of course, because you wrote this:
<span style=\"style=font-family:'Times New Roman'\">

And again this is not a HTML/CSS and setting line height to 0 won't remove the gaps - you will have to calculate that for yourself based on the current font metrics.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock positioning using returned Height and Width

Tue Nov 14, 2017 7:49 pm

Hi Alex -

Regarding line-height and the descenders getting cut off:

If the line-height setting is smaller than the equivalent of "normal" than the height of the TextBlock is wrong:

This works:
<p style=\"line-height:normal; font-family: 'Arial'; font-size:12pt;\">

- the returned height is accurate

This does not:
<p style=\"line-height:10pt; font-family:'Arial'; font-size:12pt;\">

- the returned height is not accurate, even though the line-height is adjusted.
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock positioning using returned Height and Width

Tue Nov 14, 2017 9:12 pm

Hi Alex -

Earlier in this thread you write:

We position by ascent as it should be and it is not being regulated by line gap in any cases. If the text position is top (TextBlock) then we offset by the ascent of the biggest character in the block.
...
1) You can output text in the BaseLine position by using ShowTextLine method and all of the Cap Height calculation (or what you want) should be done from your side.


What tools are in the CoreAPI that I can use to do this from my side?
If I can subtract the CapHeight from the Ascent I'll have my answer - BUT
there's a lot going on here....
First, there could be mixed Fonts and sizes in the text.
Second, the line could be wrapped or returned.
Etc....

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

Re: ShowTextBlock positioning using returned Height and Width

Wed Nov 15, 2017 7:29 am

Hello Wayne,

We don't provide a possibility to get the font's ascent and descent in the Core API - you can only get the line height overall. Also, you can output the text by the base line by using the ShowTextLine method with the STLF_Baseline flag as I mentioned before.
If I can subtract the CapHeight from the Ascent I'll have my answer - BUT
there's a lot going on here....
First, there could be mixed Fonts and sizes in the text.
Second, the line could be wrapped or returned.

Well I'm afraid this is your case and you must solve it - we only do the support not custom coding. Everything that you wrote is implemented in the ShowTextBlock method - if you don't like it then implement the logic for yourself.
By the way - the watermarks that you have output earlier done the fine job for you and you hadn't have any problems with fonts there. Why is there a problem here?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
whoit
User
Topic Author
Posts: 141
Joined: Tue Jul 07, 2015 3:30 pm

Re: ShowTextBlock positioning using returned Height and Width

Wed Nov 15, 2017 2:18 pm

Hi Alex -

My concern is that a lot of our clients require precise positioning of stamps (within the
title block of a CAD drawing for example) and I was concerned that this would mess us up.
Many fonts, like Arial, do not have ascenders like what was shown in your graphic earlier
in this thread ("h", "l", etc.).

Then a quick search on the Net reminded me that some of our clients use characters that we do not use in English,
and I'm being a dope.

For example, these two characters "Å" "Ñ" would be cropped if the box did not account for the additional ascent height
as you point out.

Sorry - it took me a while to see this!

I think I'm good for now....
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 2610
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ShowTextBlock positioning using returned Height and Width

Wed Nov 15, 2017 2:47 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest