I am creating a pdf by adding an external template image (420x297 mm [A3 landscape]) to a new page then overwriting with data from another external page (also A3 landscape according to Acrobat file|properties). The template image works ok but the data laid over the top of it is not in the correct position - all i get is the bottom left hand corner of the data page (as if it were on a portrait orientated page). Page.Rotate is 0 on the template image page but 270 on the data page and i have tried changing combinations of .Rotate and .Orientation for both the new page and the source page but none of these rectify the problem. The TwoPagesOnOne sample was used as a guideline. All help and ideas greatly appreciated.
Code:
//background PDF file
stockFilename = dataPath + "Stock.pdf";
formBackground = XPdfForm.FromFile(stockFilename);
formBackground.PageNumber = stockIndex;
//data PDF file
formData = XPdfForm.FromFile(pdfListItemDataFilename);
formData.PageNumber = dataPageNumber;
// Create the output document
outputDocument = new PdfDocument();
outputDocument.PageLayout = PdfPageLayout.SinglePage;
// Add a new page to the output document based on background (stock)
newPage = outputDocument.AddPage();
newPage.Orientation = formBackground.Page.Orientation;
width = formBackground.PointWidth;
height = formBackground.PointHeight;
newPage.Width = width;
newPage.Height = height;
gfx = XGraphics.FromPdfPage(newPage);
box = new XRect(0, 0, width, height);
gfx.DrawImage(formBackground, box);
//Draw data image
gfx.DrawImage(formData, box);