I gave it a try (as a newbie) and it works
Code:
public void MssTwoLanePDF(byte[] ssinputPDF, out byte[] ssoutputPDF) {
ssoutputPDF = new byte[] {};
MemoryStream stream = new MemoryStream(ssinputPDF);
// Create the output document
PdfDocument outputDocument = new PdfDocument();
// Show single pages
// (Note: one page contains two pages from the source document)
outputDocument.PageLayout = PdfPageLayout.SinglePage;
XGraphics gfx;
XRect box;
// Open the input document stream as XPdfForm object
XPdfForm form = XPdfForm.FromStream(stream);
double width = form.PixelWidth;
double height = form.PixelHeight;
// Add a new page to the output document
PdfPage page = outputDocument.AddPage();
page.Width = new XUnit(width * 2);
page.Height = new XUnit(height);
gfx = XGraphics.FromPdfPage(page);
// Draw first lane
//box = new XRect(0, 0, width, height);
//gfx.DrawImage(form, box);
gfx.DrawImage(form, 0, 0, width, height);
// Draw second lane
box = new XRect(width, 0, width, height);
//gfx.DrawImage(form, box);
gfx.DrawImage(form, width, 0, width, height);
// Save the document...
MemoryStream outputstream = new MemoryStream();
//Save the document into stream
outputDocument.Save(outputstream);
//Save the stream as a file in the ssoutputPDF variable
ssoutputPDF = outputstream.ToArray();
I couldn't use XRect because the output 2 PDF's were out of proportion. No idea why.
One question left, how can I achieve a margin of 1mm in the output PDF on these four positions:
- Left of the first lane
- Between the two lanes
- Right of the last lane
- Below the 2 PDF's in every lane