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!
Font Handling |
Post Reply |
Author | |
MrPopup
Team Player Joined: 19 Dec 05 Location: New Zealand Status: Offline Points: 32 |
Post Options
Thanks(0)
Posted: 13 Aug 20 at 1:27AM |
Hi folks, I want to generate multiple single page documents (invoices) that are appended to an email for distribution.A number of fonts are used so at present I create a pdf instance, add the fonts, generate the single page, saveToFile and delete the pdf instance! Repeating the process for every invoice. Is there a mechanism that would allow me to just have a single pdf instance and thus only have to add the fonts once? It seems that if I use the Document capability, I still have to add the fonts each time. Many thanks. Cheers.
|
|
MrPopup
|
|
Jack
Team Player Joined: 03 Jun 09 Location: Lompoc, CA Status: Offline Points: 22 |
Post Options
Thanks(0)
|
I would like to have tried out this solution so I could tell you that it works. I have to print a lot of forms at the end of the year and the file size gets pretty big when I do. When I get the time, what I intend to do is create one page that has the form background on it and then Clone that page with the function that comes with the Delphi version of the library listed in the reference guide as: function TDebenuPDFLibrary1711.ClonePages(StartPage, EndPage, RepeatCount: Integer): Integer; I believe this will cause just one version of the page to be created and as many copies as RepeatCount calls for. Then, I can reference these additional pages to populate them with the data I need to report. It seems like this would solve the embedded fonts for you and fix my file size and speed issues. But I haven't tried it yet. Cheers back. Jack
|
|
Jack
Team Player Joined: 03 Jun 09 Location: Lompoc, CA Status: Offline Points: 22 |
Post Options
Thanks(0)
|
I should have said "as many references" of that page rather than copies. I think the visual forms are created inside the PDF viewer as needed sort of like calling a subroutine. Jack
|
|
MrPopup
Team Player Joined: 19 Dec 05 Location: New Zealand Status: Offline Points: 32 |
Post Options
Thanks(0)
|
Good morning Jack (well it's morning where I am!),
Thank you for the response. I have yet to give it a try but am looking at the option suggested. What I am trying now is: create pdf instance set document properties, page dimensions, fonts, images, etc loop build the single page document set unique file name saveToFile //save the current document pdf.newPage //add a page 2 to the current document pdf.deletePage(1,1) //delete page 1 of the current document //what was page 2 is now the current page endLoop delete pdf instance I have yet to prove that this will work, but am hopeful as it should be really fast and generate relatively small files. Will provide an update should I be successful. Again, thanks. Cheers
|
|
MrPopup
Team Player Joined: 19 Dec 05 Location: New Zealand Status: Offline Points: 32 |
Post Options
Thanks(0)
|
OK, so I tried the code as indicated in the prior post.
There is a wee problem in the pdf library so the revised code, that WORKS is: create pdf instance set document properties, page dimensions, fonts, images, etc loop build the single page document if pdf.pageCount > 1 then pdf.deletePages(1,1) //delete the prior page endif; //this leaves the last page only in the document set unique file name saveToFile //save the current document pdf.newPage //add a page 2 to the current document, now the current page endLoop delete pdf instance The library seems not to correctly handle deleting a page if the only other page has not been 'touched'. Hence the code rework. Using my original code (a new pdf instance for every invoice) it took 69 seconds for 100 pages. Using the above code it now takes 29 seconds - 40 seconds saving. Interestingly, the individual pdf file sizes are larger! 635KB under the old method and 880KB under the new faster method. No visible difference in the output and same compression etc used. Will try and figure out why! Cheers |
|
MrPopup
|
|
MrPopup
Team Player Joined: 19 Dec 05 Location: New Zealand Status: Offline Points: 32 |
Post Options
Thanks(0)
|
Further to the file size issue.
Generating 100 identical pages using the code in the prior post produces pdf files that grow larger by 3KB per file. ie first pdf generated is 625 KB and the 100th pdf generated is 940 KB! I have to assume that the pdf dll is not fully clearing up after a deletePages() call. So the question is the huge performance increase out weighted by the increasing file sizes! I guess I could create a new pdf instance every 100 or so files. Cheers. |
|
MrPopup
|
|
MrPopup
Team Player Joined: 19 Dec 05 Location: New Zealand Status: Offline Points: 32 |
Post Options
Thanks(0)
|
An apology and correction.
The reason for the constantly increasing pdf file size (as posted above) was my error NOT a fault with the dll library. I was still adding some fonts for each page unnecessarily. My bad! Correcting this has also improved the performance results - it now takes just 23 seconds verses the original 109 seconds - a reduction of 46 seconds (42%). I am one happy chappie!
|
|
MrPopup
|
|
Jack
Team Player Joined: 03 Jun 09 Location: Lompoc, CA Status: Offline Points: 22 |
Post Options
Thanks(0)
|
I'm glad you got such good results. I will try the process I proposed later this year. The process I currently use only loads the fonts once, but copies a new instance of the form template multiple times, pre-pends a page number on each form field to give them unique names and then fills in the fields. Performance suffers as the page count goes up so I think I could not use this method if the page count goes over 500. Acrobat can copy the same logo or watermark on each page without appending it multiple times so I think making the form background like a logo or watermark should work similarly. Thanks for posting the results of your further efforts. It sounds like you have a very good process. Jack
|
|
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