Hi,
Here is the relevant text from the PDF specification:
The user space coordinate system shall be initialized to a default state for each page of a document. The CropBox entry in the page dictionary shall specify the rectangle of user space corresponding to the visible area of the intended output medium (display window or printed page). The positive x axis extends horizontally to the right and the positive y axis vertically upward, as in standard mathematical practice (subject to alteration by the Rotate entry in the page dictionary). The length of a unit along both the x and y axes is set by the UserUnit entry (PDF 1.6) in the page dictionary (see Table 30). If that entry is not present or supported, the default value of 1⁄72 inch is used. This coordinate system is called default user space.
Here is a code snippet that specifies coordinates in CM and takes into account everything mentioned in the previous quote (CropBox, Rotate, and UserUnit page entries):
var scale = 2.54 / 72;
var quad = new PdfQuad(new PdfPoint(300 * scale, 100 * scale), new PdfPoint(550 * scale, 100 * scale), new PdfPoint(550 * scale, 150 * scale), new PdfPoint(300 * scale, 150 * scale));
var page = document.Pages[0];
var transform = PdfMatrix.Identity;
transform.Scale(scale, scale);
transform = page.Transform * transform;
transform.Invert();
transform.Transform(ref quad);
var signatureField = document.Form.Fields.AddSignature(page, quad.Left, quad.Bottom, quad.Right - quad.Left, quad.Top - quad.Bottom);
var signatureAppearance = signatureField.Appearance;
signatureAppearance.Orientation = page.Rotate;
Here is the same code snippet that specifies coordinates in INCH:
var scale = 1.0 / 72;
var quad = new PdfQuad(new PdfPoint(300 * scale, 100 * scale), new PdfPoint(550 * scale, 100 * scale), new PdfPoint(550 * scale, 150 * scale), new PdfPoint(300 * scale, 150 * scale));
var page = document.Pages[0];
var transform = PdfMatrix.Identity;
transform.Scale(scale, scale);
transform = page.Transform * transform;
transform.Invert();
transform.Transform(ref quad);
var signatureField = document.Form.Fields.AddSignature(page, quad.Left, quad.Bottom, quad.Right - quad.Left, quad.Top - quad.Bottom);
var signatureAppearance = signatureField.Appearance;
signatureAppearance.Orientation = page.Rotate;
PdfQuad must be used as a helper because rotation doesn’t preserve orientation of coordinates.
With this code, your signature box will always be of the same absolute size and in the same absolute position when viewing the page in a PDF viewer.
Regards,
Stipo