Print Page | Close Window

Create multiple pages using same qp.LoadFromFile

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2417
Printed Date: 27 Jan 26 at 2:20PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Create multiple pages using same qp.LoadFromFile
Posted By: Halv
Subject: Create multiple pages using same qp.LoadFromFile
Date Posted: 25 Sep 12 at 1:47AM
Greetings,

Alright I have another question again. I am trying to create multiple pages of the same PDF file. I am trying to use qp.NewPage and use the same PDF file I'm loading with qp.LoadFromFile to appear in the new page as well, but so far it only appears in the first page, while the second page and so on is a blank page. If anyone has any tips on how I could get the qp.LoadFromFile to appear in every page I'd appreciate it a lot.

Halv



Replies:
Posted By: AndrewC
Date Posted: 25 Sep 12 at 2:24AM

Here some code to copy a single page PDF and create a pdf with 20 copies of page 1.  You may also want to look at ClonePages in the Refererence guide.

Also, a very good place to get up to speed with the library is to read the PDF Developer Guide PDF that is in the Quick PDF installation folder.  It will help explain how this code works.

  QP.LoadFromFile("1page.pdf");

  double pw = QP.PageWidth();
  double ph = QP.PageHeight();

  QP.NewPage();   // Add a 2nd blank page and selects it as the current page.

  int id = QP.CapturePage(1);    // Capture the contents of page 1.

  for (int i = 1;i<=20;i++)
  {
    if (i != 1)
      QP.NewPage();  // add an extra new page.  We already have page 1.

    QP.SelectPage(i);
    QP.SetOrigin(1);
    QP.SetPageDimensions(pw, ph);
    QP.DrawCapturedPage(id, 0, 0, pw, ph);    // Draw the captured page on to each page.
  }
   QP.SaveToFile("20pages.pdf");

Andrew.


Posted By: Halv
Date Posted: 26 Sep 12 at 1:32AM
Greetings,

Andrew I tried the code sample you wrote down but I couldn't get it to work. I tried changing some parts here and there but could not get my qp.LoadFromFile to be captured and drawn to the other pages.

So I looked into qp.ClonePages and I managed to get it working. It's a small example but this is how I'm using it.

if (rowCount > 14)
            {
                qp.ClonePages(1, 1, Convert.ToInt32(System.Math.Ceiling(rowCount / 14.0))- 1);
                qp.SelectPage(1);
            }

Basically the PDF file that I am loading has only 14 fields, so with this it counts how many rows there are beforehand and will make additional pages as needed.

Thanks again for your help Andrew!

Halv



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk