Taking into account effect of page rotation when adding new content to a page.

126 views
Skip to first unread message

Support

unread,
Aug 6, 2008, 6:28:29 PM8/6/08
to PDFTron PDFNet SDK
Q: We are stamping PDF documenents using PDFNet. For some of the
files the pages go landscape. We are able to detect the page rotation
using the page.GetPageRotation, however the text we add to the page is
appearing upsidedown (i.e. is rotated).

Can we take into account effects of page rotation so that the
watermark is effectively right side up for users?

---
A: You should be able to use PDFNet API to detect page orientation/
rotation and make corresponding adjustments to your stamping code.

There are many ways this could be implemented. Probably the simples
approach would be to use page.GetDefaultMatrix() to obtain the
rotation matrix for the page, which can then be concatenated
(multiplied) with any additional transforms. For example:

' Assuming VB.NET pseudocode
Dim mtx as Matrix2D = new Matrix2D(1, 1, 0, 1, 0, 20) 'Assuming
diagonal

' Use matrix.Inverse() to rotate the text in the opposite direction
from page rotation.
Dim def_mtx as Matrix2D = page.GetDefaultMatrix().Inverse()
mtx.Concat(def_mtx.m_a, def_mtx.m_b, def_mtx.m_c, def_mtx.m_d,
def_mtx.m_h, def_mtx.m_v)
element.SetTextMatrix(mtx)
...
Reply all
Reply to author
Forward
0 new messages