<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>Debenu Quick PDF Library - PDF SDK Community Forum : N-Up pages, 2-Up Booklet</title>
  <link>http://www.quickpdf.org/forum/</link>
  <description><![CDATA[This is an XML content feed of; Debenu Quick PDF Library - PDF SDK Community Forum : Sample Code : N-Up pages, 2-Up Booklet]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Fri, 08 May 2026 06:09:56 +0000</pubDate>
  <lastBuildDate>Mon, 21 Sep 2009 05:05:57 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 11.01</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.quickpdf.org/forum/RSS_post_feed.asp?TID=1220</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Debenu Quick PDF Library - PDF SDK Community Forum]]></title>
   <url>http://www.quickpdf.org/forum/forum_images/QPDF_Forum_Title.png</url>
   <link>http://www.quickpdf.org/forum/</link>
  </image>
  <item>
   <title><![CDATA[N-Up pages, 2-Up Booklet : N-Up is shorthand for 2-up, 3-up,...]]></title>
   <link>http://www.quickpdf.org/forum/nup-pages-2up-booklet_topic1220_post5616.html#5616</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.quickpdf.org/forum/member_profile.asp?PF=1000">Rowan</a><br /><strong>Subject:</strong> 1220<br /><strong>Posted:</strong> 21 Sep 09 at 5:05AM<br /><br /><div>N-Up is shorthand for 2-up, 3-up, 4-up etc, or basically: combining&nbsp;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.</div><div><br></div><div>-------------</div><div><div><div><font ="Apple-style-span" color="#003399">private void btnBooklet_Click(object sender, EventArgs e)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">QuickPDFAX0716.PDFLibrary QP = new QuickPDFAX0716.PDFLibrary();</font></div><div><font ="Apple-style-span" color="#003399">int result = QP.UnlockKey("...Insert_License_Key_Here...");</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">if (result == 1)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">// First, load the original document that you wish to use for this imposition test:</font></div><div><font ="Apple-style-span" color="#003399">QP.LoadFromFile(@"C:\Program Files\Quick PDF Library\Quick PDF Library 7.16 Reference Guide.pdf");</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Then we get the number of pages in the original document:</font></div><div><font ="Apple-style-span" color="#003399">int originalPageCount = QP.PageCount();</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Store the width and height of the pages from the original document:</font></div><div><font ="Apple-style-span" color="#003399">double w = QP.PageWidth();</font></div><div><font ="Apple-style-span" color="#003399">double h = QP.PageHeight();</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Use the CapturePage function to capture every page in the original document.</font></div><div><font ="Apple-style-span" color="#003399">// Each captured page will be given a unique ID which can be used with the</font></div><div><font ="Apple-style-span" color="#003399">// DrawCapturedPage function. Temporarily store these ID's in an array:</font></div><div><font ="Apple-style-span" color="#003399">int&#091;&#093; capture = new int&#091;originalPageCount&#093;;</font></div><div><font ="Apple-style-span" color="#003399">int indexArray = 0;</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">for (int pageTest = 1; pageTest &lt;= originalPageCount; pageTest++)&nbsp;</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">capture&#091;indexArray&#093; = QP.CapturePage(1);</font></div><div><font ="Apple-style-span" color="#003399">indexArray++;</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">if (QP.PageCount() == 1)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">// After a page has been captured it's removed from the document in memory,</font></div><div><font ="Apple-style-span" color="#003399">// but we can't have a document with no pages, so a temporary page must be</font></div><div><font ="Apple-style-span" color="#003399">// created until the imposed pages have been added to the document.</font></div><div><font ="Apple-style-span" color="#003399">QP.NewPage();</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">int requiredPages = 0;</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Now calculate the required number of pages for the 2-up booklet:</font></div><div><font ="Apple-style-span" color="#003399">if (originalPageCount == 1)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">requiredPages = 1;</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">else</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">requiredPages = originalPageCount / 2;</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Add the required number of pages to the end of the document, using the NewPages function:</font></div><div><font ="Apple-style-span" color="#003399">QP.NewPages(requiredPages);</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">int captureIndex = 0;</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Now loop through each new page in the document and draw the captured pages. Two captured</font></div><div><font ="Apple-style-span" color="#003399">// pages will be drawn on each new page. The first captured page is drawn on the left, the</font></div><div><font ="Apple-style-span" color="#003399">// second on the right, and then it moves on to the next new page and repeats the process:</font></div><div><font ="Apple-style-span" color="#003399">for (int page = 1; page &lt;= requiredPages + 1; page++)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">QP.SelectPage(page);</font></div><div><font ="Apple-style-span" color="#003399">QP.SetPageDimensions(w * 2, h);</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">for (int i = 0; i &lt;= 0; i++)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">if (i &lt;= 1)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">// Draw left</font></div><div><font ="Apple-style-span" color="#003399">if (captureIndex != capture.Length)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">QP.DrawCapturedPage(capture&#091;captureIndex&#093;, 0, h, w, h);</font></div><div><font ="Apple-style-span" color="#003399">QP.DrawText(100, 25, "Page: " + captureIndex);</font></div><div><font ="Apple-style-span" color="#003399">captureIndex++;</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">// Draw right</font></div><div><font ="Apple-style-span" color="#003399">if (captureIndex != capture.Length)</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">QP.DrawCapturedPage(capture&#091;captureIndex&#093;, 560, h, w, h);</font></div><div><font ="Apple-style-span" color="#003399">QP.DrawText(w, 25, "Page: " + captureIndex);</font></div><div><font ="Apple-style-span" color="#003399">captureIndex++;</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">// Delete the extra page that was created when the original pages were captured</font></div><div><font ="Apple-style-span" color="#003399">QP.DeletePages(QP.PageCount(), 1);</font></div><div><font ="Apple-style-span" color="#003399"><br></font></div><div><font ="Apple-style-span" color="#003399">// Save the new 2-up booklet</font></div><div><font ="Apple-style-span" color="#003399">QP.SaveToFile(@"C:\temp\Manual_Booklet.pdf");</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">else</font></div><div><font ="Apple-style-span" color="#003399">{</font></div><div><font ="Apple-style-span" color="#003399">MessageBox.Show("Sorry, but the license key you provided could not be validated.");</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div><font ="Apple-style-span" color="#003399">}</font></div><div>-------------</div></div></div>]]>
   </description>
   <pubDate>Mon, 21 Sep 2009 05:05:57 +0000</pubDate>
   <guid isPermaLink="true">http://www.quickpdf.org/forum/nup-pages-2up-booklet_topic1220_post5616.html#5616</guid>
  </item> 
 </channel>
</rss>