|
Rank: Newbie Groups: Member
Joined: 6/19/2014 Posts: 9
|
Hi,
I am evaluating the library and was playing with the low level API (before moving to the higher level one) and I don't quite get what the PositionMode property is supposed to do when assigned the value PdfTextPositionMode.NextLine
It doesn't seem to do anything : for instance,
PdfTextContent t = new PdfTextContent("This is my first line."); t.Offset = new PdfPoint(50, 300); layer.Contents.Add(t);
t = new PdfTextContent("This is my second line"); t.PositionMode = PdfTextPositionMode.NextLine; layer.Contents.Add(t);
will just write the two strings on top of each other.
What am I missing ?
Thanks
Blaise
|
|
Rank: Newbie Groups: Member
Joined: 6/19/2014 Posts: 9
|
Turns out I understand even less than I thought. The Offset positioning is strange a well :
t = new PdfTextContent("A"); t.Offset = new PdfPoint(10, 250); layer.Contents.Add(t); t = new PdfTextContent("B"); t.Offset = new PdfPoint(0, 0); layer.Contents.Add(t); t = new PdfTextContent("C"); t.Offset = new PdfPoint(0, 0); layer.Contents.Add(t); page.Contents.Add(layer);
will print ABC
whitch suggest that offset is based on the bottom right of the last text.
however,
t = new PdfTextContent("A"); t.Offset = new PdfPoint(10, 200); layer.Contents.Add(t); t = new PdfTextContent("B"); t.Offset = new PdfPoint(0, 0); layer.Contents.Add(t); t = new PdfTextContent("C"); t.Offset = new PdfPoint(0, -15); layer.Contents.Add(t); page.Contents.Add(layer);
will print
AB C
and not AB ....C (dots are just here for formatting)
As I would have expected. (the second C is not below the first C, but below and to the left dispite the offset x part beeing 0 in both cases)
Anybody can shed light on this behavior ?
Thx
Blaise
|
|
Rank: Newbie Groups: Member
Joined: 6/19/2014 Posts: 9
|
I guess if somebody could tell me what the code actually does with the pdf text operators (Td, TD, Tm, T*, Tj and ' ) that would clarify things.
(Can't look at the code since it is obfuscated)
|
|
Rank: Newbie Groups: Member
Joined: 6/19/2014 Posts: 9
|
Ok, so after looking closely at the generated pdf, it seems that the following things happens:
PdfTextContent Offset mode with null Offset or 0 Offset => Tj PdfTextContent Offset mode with non 0 Offset => Td + Tj PdfTextContent NextLine mode => T* + Tj
This is actually very disturbing because 0 0 Td blahblah Tj is not at all equivalent to just blahblah Tj (can be shown by setting Offset to 0.1 0.1 and look at the output of a second text block after a first one : with 0 0 it will be appended; with 0.1 0.1 it will overwrite)
There is no way to output a TD as far as I know, so no way to set the internal leading and thus make use of the T* operator (NextLine mode)
So it seems to me that this low-lever API cannot really be used or, again, am i missing something important ?
Thanks
Blaise
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Thanks for the additional information. We were able to reproduce the problem and were trying to get more information so that we could give you a precise answer.
You are correct about the position mode. The NextLine mode moves the line down by "text leading amount", which is to be set by TD. This was to be set through GfxState.TextState.Leading, which would be translated into TL in order for PdfTextPositionMode.NextLine to work property. However neither TextState nor Leading are exposed/documented because nobody ever use it (until now you stumbled onto it). Those properties exist but are obfuscated in the final release version, which makes it unusable since the final obfuscated name can change between every builds.
Very few people use our low level API on such a in depth level since if you know all the details of PDF operator, it will probably be easier to use a COS objects level API, which is even one level lower than our low level API. In your case, one workaround is since you know you would need to set TD and the same can be done with Offset, I would recommend you to use Offset instead. I believe this is what our higher level API such as AcmText uses.
Hope this helps. Once again I apologize for the delay. Please feel free to let us know if you have any more questions.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
|
|