PDF Flag annotations

2.2k Views Asked by At

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??

1

There are 1 best solutions below

0
On BEST ANSWER

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.