Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
N-Up pages, 2-Up Booklet |
Post Reply |
Author | |
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(1)
Posted: 21 Sep 09 at 5:05AM |
N-Up is shorthand for 2-up, 3-up, 4-up etc, or basically: combining more than one different page together on the same sheet. The snippet of code below shows you how to combine two pages from a document onto one sheet in a new document. The sample doesn't include much error handling and has not been optimized as it is intended as a starting point only. ------------- 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."); } } ------------- |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store