Print Page | Close Window

SetPageDimensions Problem

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=180
Printed Date: 25 Nov 24 at 2:41AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: SetPageDimensions Problem
Posted By: Martin
Subject: SetPageDimensions Problem
Date Posted: 15 Nov 05 at 8:29PM

I am trying to change the dimensions of an existing page and the result is that the page gets resized but all of the content that was previously on the is removed.  Is this the  proper result of the method or is there another way to resize an existing page.

 

 



-------------
Martin



Replies:
Posted By: Ingo
Date Posted: 16 Nov 05 at 1:18AM
Hi Martin!
I didn't try it out but ...
What about creating a new and empty page with the new dimensions and then copy the old page into the new page?
Perhaps it helps working additional with GetPageContent on the old page and SetPageContent on the new page (after resizing).
Good luck.

-------------
Cheers,
Ingo



Posted By: Ingo
Date Posted: 16 Nov 05 at 1:22AM
Me again ;-)

Here's some code from the "original" QuickPDF-website. It seems to feed your needs?

First, load the original document:
QP.LoadFromFile("original.pdf")

It will be easier if we set the origin to the top-left corner of the page, use the SetOrigin function:
QP.SetOrigin(1)

Then we get the number of pages in the original document:
originalPageCount = QP.PageCount()

Now calculate the required number of pages for the booklet:
if (originalPageCount == 1) requiredPages = 1; else
requiredPages = (floor(originalPageCount - 1) / 4) * 2

Store the size of the pages in the original document:
w = QP.PageWidth()
h = QP.PageHeight()

Add the required number of pages to the end of the document, using the NewPages function:
QP.NewPages(requiredPages)

Now capture the original pages:
for (page = 1; page <= originalPageCount; page++) {
capture[page] = QP.CapturePage(1)
}

Draw the first set of pages, alternate right/left:
captureIndex = 1
drawLeft = false
for (page = 1; page <= requiredPages; page++) {
QP.SelectPage(page)
QP.SetPageDimensions(h, w)
if (drawLeft) x = 0; else x = h / 2
QP.DrawCapturedPage(capture[captureIndex], x, 0, h / 2, w)
captureIndex++
drawLeft = !drawLeft
}

Draw the remaining pages, alternate left/right:
for (page = requiredPages;
   (page >= 1) && (captureIndex <= originalPageCount);
   page--) {
QP.SelectPage(page)
if (drawLeft) x = 0; else x = h / 2
QP.DrawCapturedPage(capture[captureIndex], x, 0, h / 2, w)
captureIndex++
drawLeft = !drawLeft
}

Now save the booklet you have just created to a file:
QP.SaveToFile("booklet.pdf")


-------------
Cheers,
Ingo




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