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 - Change PageSize Midway?
  FAQ FAQ  Forum Search   Register Register  Login Login

Change PageSize Midway?

 Post Reply Post Reply
Author
Message
waynefulcher View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Jun 08
Location: United States
Status: Offline
Points: 99
Post Options Post Options   Thanks (0) Thanks(0)   Quote waynefulcher Quote  Post ReplyReply Direct Link To This Post Topic: Change PageSize Midway?
    Posted: 04 Aug 10 at 10:33PM
I have some data that will be passed to my function which will generate a PDF. The problem is I have no way "ahead of time" to know if this data will fit on letter or require legal.
The idea here is I need the document to be on letter if it will all fit and if not switch to legal as a preference to having 2 letter pages.
It will be a tremendous amount of work to "preprocess" the entire document with all the data being passed in to calculate the total height of all the data since there are many different headings which use different fonts and text sizes. Also I tried initializing my page size to letter and then draw the text to the page until I could see that the text would not fit then I tried to just switch the pagesize to legal mid-stream. That did not work as all the text drawn before switching the page size seemed to be centered vertically on the legal page. I also tried initializing it to legal, drawing my text and when done if it used less than was needed for letter then I switched the page size to letter but then about half the text was off the top of the page. Does anyone know if this can be done reliably or do I just have to process all the data twice, once for the math of it to decide the total height and then once to actually print?
Thanks for your help.
Back to Top
waynefulcher View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Jun 08
Location: United States
Status: Offline
Points: 99
Post Options Post Options   Thanks (0) Thanks(0)   Quote waynefulcher Quote  Post ReplyReply Direct Link To This Post Posted: 05 Aug 10 at 4:15PM
For future readers I figured out how to change the pagesize after drawing to a page has already occured and be able to keep the data. Now if you switch from legal down to letter then obviously what was draw below the bottom  of a letter size page will get cut off. But switching from Letter to Legal appears to work just fine.
 
procedure ChangePageSize(PDF: TQuickPDF0719; NewPageSize: String) ;
var
  i, pc: Integer ;
  aCapPageID: array of Integer ;
  OrigPageWidth: Double ;
  OrigPageHeight: Double ;
begin
  pc := PDF.PageCount ;
  OrigPageWidth := PDF.PageWidth ;
  OrigPageHeight := PDF.PageHeight ;
  SetLength(aCapPageID, pc) ;
  for i := 1 to pc do begin
    PDF.NewPage ;
    aCapPageID[i-1] := PDF.CapturePage(1) ;
  end ;

  PDF.SetOrigin(1) ; // Top-Left
  PDF.SetPageSize(NewPageSize) ;

  for i := 1 to pc do begin
    PDF.SelectPage(i) ;
    PDF.DrawCapturedPage(aCapPageID[i-1], 0, 0, OrigPageWidth, OrigPageHeight) ;
  end ;
end ;

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