private void btnBooklet_Click(object sender, EventArgs e)
{
QuickPDFAX0716.PDFLibrary QP = new QuickPDFAX0716.PDFLibrary();
int result = QP.UnlockKey("...Insert_License_Key_Here...");
if (result == 1)
{
// First, load the original document that you wish to use for this imposition test:
QP.LoadFromFile(@"C:\Program Files\Quick PDF Library\Quick PDF Library 7.16 Reference Guide.pdf");
// Then we get the number of pages in the original document:
int originalPageCount = QP.PageCount();
// Store the width and height of the pages from the original document:
double w = QP.PageWidth();
double h = QP.PageHeight();
// Use the CapturePage function to capture every page in the original document.
// Each captured page will be given a unique ID which can be used with the
// DrawCapturedPage function. Temporarily store these ID's in an array:
int[] capture = new int[originalPageCount];
int indexArray = 0;
for (int pageTest = 1; pageTest <= originalPageCount; pageTest++)
{
capture[indexArray] = QP.CapturePage(1);
indexArray++;
if (QP.PageCount() == 1)
{
// After a page has been captured it's removed from the document in memory,
// but we can't have a document with no pages, so a temporary page must be
// created until the imposed pages have been added to the document.
QP.NewPage();
}
}
int requiredPages = 0;
// Now calculate the required number of pages for the 2-up booklet:
if (originalPageCount == 1)
{
requiredPages = 1;
}
else
{
requiredPages = originalPageCount / 2;
}
// Add the required number of pages to the end of the document, using the NewPages function:
QP.NewPages(requiredPages);
int captureIndex = 0;
// Now loop through each new page in the document and draw the captured pages. Two captured
// pages will be drawn on each new page. The first captured page is drawn on the left, the
// second on the right, and then it moves on to the next new page and repeats the process:
for (int page = 1; page <= requiredPages + 1; page++)
{
QP.SelectPage(page);
QP.SetPageDimensions(w * 2, h);
for (int i = 0; i <= 0; i++)
{
if (i <= 1)
{
// Draw left
if (captureIndex != capture.Length)
{
QP.DrawCapturedPage(capture[captureIndex], 0, h, w, h);
QP.DrawText(100, 25, "Page: " + captureIndex);
captureIndex++;
}
// Draw right
if (captureIndex != capture.Length)
{
QP.DrawCapturedPage(capture[captureIndex], 560, h, w, h);
QP.DrawText(w, 25, "Page: " + captureIndex);
captureIndex++;
}
}
}
}
// Delete the extra page that was created when the original pages were captured
QP.DeletePages(QP.PageCount(), 1);
// Save the new 2-up booklet
QP.SaveToFile(@"C:\temp\Manual_Booklet.pdf");
}
else
{
MessageBox.Show("Sorry, but the license key you provided could not be validated.");
}
}
-------------