Page 1 of 1

Stroke/Outline issue with ShowTextBlock

Posted: Mon Apr 16, 2018 2:37 pm
by whoit
Hi -

I'm using ContentCreator and ShowtextBlock to add text to my PDF, and I've found an issue when using
Stroke and font size.

Even though I'm using CoreAPI, I've replicated the problem in PDF-XChange Editor and used the screenshots here.

The issue is that the Stroke Width is not absolute, but seems tied to the Font Size instead which gives unusable output.

If you compare these two screenshots, you can see that the only change is the Font Size, but the result has vastly different
strokes:

Image

Image

I would expect the 0.7pt stroke to appear exactly the same, but clearly it does not....
I have the same issue when using Stroke via CoreAPI.

Re: Stroke/Outline issue with ShowTextBlock

Posted: Tue Apr 17, 2018 7:16 am
by Sasha - Tracker Dev Team
Hello Wayne,

Well you have the "Scale relative to target page" checkbox enabled - try experimenting without it.

Cheers,
Alex

Re: Stroke/Outline issue with ShowTextBlock

Posted: Tue Apr 17, 2018 1:12 pm
by whoit
Unchecking 'relative' only makes the font size exact (instead of auto-scaling up to fit).

However, when the font size is small, the stroke is still way too large:

Image

Plus, since I'm using CoreAPI I would need an equivalent to "scale relative".
I'm also auto-scaling to fit the diagonal and getting the same problem that I originally
posted - giant stroke....

Re: Stroke/Outline issue with ShowTextBlock

Posted: Tue Apr 17, 2018 1:43 pm
by Lzcat - Tracker Supp
Hi Wayne.
You have specified font size 10 pt, and stroke width 1 pt, so you result is exactly as expected.
When you using autosize you enlarging text with stroke, not just text, as you saw before (because autosize does not change font size, but change matrix that affect everything).
When using Stroke via CoreAPI how do you set stroke width and how position text with stroke? If you are changing CTM - it will affect all drawings (coordinates, line widths, fonts size). So if you want to change only font size - you should change only it, but not CTM.
HTH.

Re: Stroke/Outline issue with ShowTextBlock

Posted: Tue Apr 17, 2018 2:05 pm
by whoit
I'm using ContentCreator for the Font and Drawing (is that what you mean when you refer to CTM?)

Code: Select all

contentCreator.SetStrokeColorRGB(color.RGB);
contentCreator.SetLineWidth(1);
...
contentCreator.ConcatCS(mResMatrix);
...
contentCreator.ShowTextBlock....
So how can I keep the Stroke at a specific value (1pt, 1.5pts, etc) ?
(I see the exact same issue in the Editor as shown by my screenshots)

Re: Stroke/Outline issue with ShowTextBlock

Posted: Wed Apr 18, 2018 9:42 am
by Sasha - Tracker Dev Team
Hello Wayne,

Here's a screenshot from MS Word (that behaves like the Editor):
Capture28.PNG
About CTM:
viewtopic.php?f=66&t=25815&p=101005&hilit=CTM#p101005

What we suspect that you are doing, is changing the text box's size by using the matrix that you have specified and this, of course, changes the Font Size and the Stroke Width accordingly. We'll need a full code sample on what you are doing to tell for sure.
If you want the correct behavior, you would first need to calculate the correct font size by the resulting rectangle size and then place it with the needed stroke.

Cheers,
Alex

Re: Stroke/Outline issue with ShowTextBlock

Posted: Wed Apr 18, 2018 12:53 pm
by whoit
Hi Alex -

I reviewed the word sample, and you're right (again!) - I was being stupid and confusing font size with thickness.
So, yes, I need a way to apply the stroke after the scaling of the font....

The code I'm using is actually code that you supplied here: viewtopic.php?f=67&t=29823

Re: Stroke/Outline issue with ShowTextBlock

Posted: Thu Apr 19, 2018 5:47 am
by Sasha - Tracker Dev Team
Hello Wayne,

Well, the algorithm should be like this:
1) You calculate the rectangle for the font size (name, parameters) that you need.
2) Then you take the size of the rectangle that you will need to put the text into.
3) Calculate the new font size based on the rectangle proportions scale coefficient (new height/old height).
4) Output the font with the new size and apply stroke to it.

Cheers,
Alex