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

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

' 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)