PDF: How starting Position is Calculated through TM and TD

pdf, pdf-generation

Solution

You are missing that `Tm` sets a matrix, not just the font size:

10 0 0 10 144.857 475.09 Tm   <-New settings Fontsize=7.5 and x and Y axis

In addition to the font scale, this also sets the origin at `137.289 475.09`. Next, the instruction

-4.5857 -1.3 TD        <- What x-axis?

moves `-4.5857` 'units' across and `-1.3` 'units' down. The size of the units is in text space, that is, scaled horizontally by `10` and vertically by `10` -- two separate calculations. That comes down to horizontally -45.857 and vertically -13 units, in graphics space and relative to the origin:

137.289 + 10*-4.5857 = 91.432 (horizontal)
475.09  + 10*-1.3    = 462.09 (vertical)

Problem

I reading PDF Specification and unable to calculate the starting offset of x axis the visible text is as under: ``` Preface vii Acknowledgments ix INTRODUCTION 3 ``` PDF Text uncompress stream text as under: ``` 10 0 0 10 99 475.09 Tm <-New setting fontsize=10 and x and y axis -.2 Tc <-Character spacing [( P)-207(r)-181(e)-211(f)-187(a)-207(c)-191(e)-200( )-500( )-500( )]TJ ^Array having text /F2 1 Tf <-New font is set 7.5 0 0 7.5 137.289 475.09 Tm <-New settings Fontsize=7.5 and x and Y axis .002 Tc <-Character spacing (vii)Tj <-Text String /F6 1 Tf <-New Font 10 0 0 10 144.857 475.09 Tm <-New settings Fontsize=10 and x and Y axis -.2 Tc <-Character spacing ( )Tj <-Text String ``` What would be new x axis and y axis now ``` -4.5857 -1.3 TD <- What x-axis? [( A)-226(c)-190(k)-202(n)-201(o)-197(w)-192(l) -199(e)-200(d)-211(g)-216(m)-200(e)-201(n)-204(t)-201(s) -200( )-500( )-500( )]TJ /F2 1 Tf <- New Font 7.5 0 0 7.5 178.759 462.09 Tm <-New Text Matrix 0 Tc <-Character spacing (ix)Tj <- text string /F6 1 Tf 10 0 0 10 184.309 462.09 Tm -.2 Tc ( )Tj ``` Means x axis must be equal to 462.09? But how it is calculated ``` /F2 1 Tf 7 0 0 7 99.4 434.09 Tm .1599 Tc -.3799 Tw [( IN)-19.1(T)-10.1(R)1.9(ODUCT)-20.1(I)6.9(O)6.9(N)-.1( )-660( )-660( )]TJ /F2 1 Tf -5.5427 -1.8857 TD -.22 Tc [( )-42.9( )]TJ 7 0 0 7 99.6 407.69 Tm .1663 Tc [(CH)5.3(APT)-13.7(E)2.3(R)6.3( )]TJ ``` Again the Same thing repeting but how to calculate x axis position

Original source

Related problems