Attached is a zip of a sample program I wrote to demonstrate the
problem I'm having stamping. Specifically, the second document,
ncwd-119.pdf, has a non-standard coordinate system. Ideally the
stamped text would appear in the same location on all four pages, but
because of the problems with 119 the text is appearing in a strange
location and much smaller (way off to the left instead of near the
The program flow (see MergeAndStamp) is very simple, initialize pdfnet,
create a new pdf for output, merge in the two files, call the stamp
routine, save output file, launch "stamped.pdf" for your convenience.
What I NEED to do is determine what the scaling system is for a PDF so
that I can place the text in the correct location regardless of the
We looked in the files and the problem is that the documents have very
different page dimensions.
The page dimensions in 'ncwd-117.pdf' are 595,842 points
The page dimensions in 'ncwd-119.pdf' are 1696, 2200 points (this is a
very large page!)
PDF page coordinate system uses a unit called a point. One point is
1/72 of an inch.
You can use 'Rect bbox = page.GetCropBox();' to obtain the dimensions
of the cropped page.
Then, you can use bbox.Width() and bbox.Height() to calculate the
required scaling factor. For example:
double scale_factor = 595.0/page.GetCropBox().Width();
Finally 'page.GetDefaultMatrix()' is useful if you would like to obtain
a transformation matrix that maps points to 'rotated' and 'cropped'
page coordinates. This will not help with the scaling issue but would
be useful if the pages have extra rotation property applied to them