[poppler] [PATCHES] Support for the NoRotate annotation flag

Fabio D'Urso fabiodurso at hotmail.it
Thu Mar 21 11:48:11 PDT 2013


Hi,

the attached patches implement support for the NoRotate annotation flag, which 
tells that the annotation must *not* be rotated according to the page 
orientation or requested rendering rotation (more on this later).

The main reason why I have implemented these patches is 
https://bugs.kde.org/show_bug.cgi?id=313177, which consists in free-text 
annotations' text being wrongly oriented when the page has a /Rotate attribute 
whose value is different than 0. With the NoRotate flag, it will be possible 
to create annotations that always face the viewer, independently from the 
page's /Rotate attribute.

NoRotate annotations are somewhat tricky, because they are never rotated, 
neither according to the orientation of page, nor according to the requested 
*rendering* rotation.
I'm attaching a "orientation-examples.pdf" that shows this very important 
aspect. If you open it in acroread and rotate the pages, you'll see that 
NoRotate annotations pivot on their top-left corner and always face the 
viewer. I want to stress on this aspect: what you get if you render a page 
containing a NoRotate annotation and then apply a rotation *IS NOT* the same 
result that you would obtain by directly rendering the page at that 
rotation (see attached image for an example). This is the reason why I had to 
write patch 0004.

~ PATCHES 0001 and 0002

Patch 0001 changes the Gfx::drawAnnot method so that it "unrotates" the 
coordinate system before drawing NoRotate annotations. This is the patch that 
actually implements the NoRotate flag, and it works in all cases but 
rasterized postscript output, which is addressed in patch 0004.

Patch 0002 adds rotation control in poppler-qt4's demo application. I've used 
this patch to quickly test how NoRotate annotations behave with different 
rendering rotations.

~ PATCHES 0003 and 0004

Patch 0001 relies on GfxState's getRotate() method in order to obtain the 
currently requested rotation. Unfortunatly rasterization code in 
PSOutputDev::checkPageSlice smartly avoids a double rotation of the resulting 
image by ensuring that getRotate() is always 0 during rasterization.
In other words it asks Splash to render an image with a rotation that is 
different than the final rendering rotation and, as I've said in the previous 
paragraphs, this leads to a wrong result.
This issue can be reproduced by printing the attached document to PS with the 
forceRasterize option set (patch 0003 adds a handy "-rasterize" pdftops 
command-line flag to test this).
If you run
 pdftops -paper A4 -rasterize orientation-examples.pdf test-rasterized.ps
you'll notice that the NoRotate flag has no effect.

Patch 0004 fixes this issue by setting up splash renderings in a 
way that ensures getRotate() returns the right value. See patch 0004's commit 
message for more details.

~ PATCHES 0005 and 0006

NoRotate annotations use a different coordinate system than regular 
annotations. Patches 0005 and 0006 implement transparent coordinate conversion 
in the qt4 frontend.

In order for the conversion to work properly, patch 0006 requires clients to 
call some APIs in a strict order. This is documented in patch 0007.

~ PATCH 0007

This patch adds some bits of documentation about qt4's annotation support, 
including issues related to NoRotate annotations.

~ PATCH 0008

Small one-liner patch that is *not* related to NoRotate annotions at all.
It frees a temporary buffer I forgot to free after use when I wrote 
TextAnnotationPrivate::createNativeAnnot.

As usual, feedback is more than welcome.

Thank you,
Fabio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orientation-examples.pdf
Type: application/pdf
Size: 6891 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0001.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rotation-rendering-differences.png
Type: image/png
Size: 5341 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-core-Support-for-rendering-annotations-with-flagNoRo.patch
Type: text/x-patch
Size: 10717 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-poppler_qt4viewer-Add-combobox-to-select-rotation.patch
Type: text/x-patch
Size: 6199 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0009.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-pdftops-Added-rasterize-flag-to-force-rasterization.patch
Type: text/x-patch
Size: 1839 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0010.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-PSOutputDev-Fix-issues-with-NoRotate-annotations-in-.patch
Type: text/x-patch
Size: 8080 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0011.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-core-Remove-geometry-related-arguments-from-annotati.patch
Type: text/x-patch
Size: 11047 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0012.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-qt4-FixedRotation-annotations-coordinate-conversion.patch
Type: text/x-patch
Size: 13884 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0013.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-qt4-Some-documentation-about-annotations.patch
Type: text/x-patch
Size: 8083 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0014.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-qt4-Free-some-temporary-memory-in-TextAnnotationPriv.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20130321/da97bf4c/attachment-0015.bin>


More information about the poppler mailing list