0

I try to (programmatically) write the page numbers to all pages in a PDF file. The object I use to write looks like this:

493 0 obj
<</Length 96>>
stream
Q
/2 12 Tf
/DeviceRGB cs
0 0 0 scn
q
1 0 -0 1 298 32 cm
BT
1 0 0 1 -3.6 1.884 Tm
(2) Tj
ET
Q
endstream
endobj

It worked fine, until I tried to do it on a page which uses the flag "/rotate" :

23 0 obj
<</Parent 2 0 R /Rotate 180 /Contents [492 0 R 24 0 R 493 0 R ] ... >>
...

When tried to do so, the number I wrote came upside down (and in the top of the page instead of bottom).

I read about this in the PDF manual, and found I can use the annotation flags, indicating I want the written number to be fixed, and not effected by page rotation.

For that, I tried to add to the 493 obj dictionary the corresponding flag (NoRotate):

493 0 obj
<</Length 96 /F 16>>
stream
...

The only thing that actually happens is that the number I try to write doesn't show at all.

I tried to load different numbers into the "/F", but they all lead to an invisible number.

I tried to look for examples in the manual and over the net, but didn't find.

What am I doing wrong? Maybe I place the "/F" in the wrong location??

Jongware
  • 22,200
  • 8
  • 54
  • 100
user1028741
  • 2,745
  • 6
  • 34
  • 68
  • I guess this is the answer, if you post it as an answer I'll accept it. Thank you. – user1028741 Jan 12 '14 at 00:24
  • A side remark: you set the font outside a text object. Strictly speaking that is not allowed. – mkl Jan 12 '14 at 08:43
  • @mkl, I've been told that before, I didn't find any documentation that suggests it's forbidden. It does make sense though. Unfortunately I work with a pdf package which does that (I cannot control it). Thanks. – user1028741 Jan 12 '14 at 12:00
  • 1
    The PDF specification pretty clearly defined which operations are allowed when. – mkl Jan 12 '14 at 18:40

1 Answers1

1

According to Adobe's PDF Reference v1.7 (link to PDF), 8.4.2 Annotation Flags, the flag /F only applies to annotations -- objects with a /Type of /Annot, and appearing in a PDF as sticky notes, text edits, and clickable rectangles.

It seems you have to provide the rotation yourself, using the Tm operator.

Jongware
  • 22,200
  • 8
  • 54
  • 100