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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Create multiple pages using same qp.LoadFromFile
  FAQ FAQ  Forum Search   Register Register  Login Login

Create multiple pages using same qp.LoadFromFile

 Post Reply Post Reply
Author
Message
Halv View Drop Down
Beginner
Beginner


Joined: 17 Sep 12
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Halv Quote  Post ReplyReply Direct Link To This Post Topic: Create multiple pages using same qp.LoadFromFile
    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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.


Edited by AndrewC - 26 Sep 12 at 2:19AM
Back to Top
Halv View Drop Down
Beginner
Beginner


Joined: 17 Sep 12
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Halv Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store