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!
Change PageSize Midway? |
Post Reply |
Author | |
waynefulcher
Senior Member Joined: 23 Jun 08 Location: United States Status: Offline Points: 99 |
Post Options
Thanks(0)
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.
|
|
waynefulcher
Senior Member Joined: 23 Jun 08 Location: United States Status: Offline Points: 99 |
Post Options
Thanks(0)
|
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 for i := 1 to pc do begin |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store