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!
![]() |
Creating large PDFs from PNG files |
Post Reply ![]() |
Author | |
Eric24 ![]() Team Player ![]() ![]() Joined: 28 Jun 09 Location: Dallas, TX Status: Offline Points: 29 |
![]() ![]() ![]() ![]() ![]() Posted: 28 Jun 09 at 8:39PM |
I've been looking at the various QPDFL functions and I'm not sure what the best approach is for this; hopefully someone has done this before and has some pointers...
I have a potentially large number of PNG files (too large to do this all in memory, so looking at a way to use DA functions for all or part of the process) that I need to convert into a single PDF file, where each page of the PDF is simply one of the PNGs. My general thinking is to do something like this: For each PNG: > NewDocument > NewPage > InsertPages (one page) > AddImageFromFile > DrawImage (onto new page) > SaveToFile (single page PDF) Then, use DA functions (to do the merging on disk)... > DAOpenFile (output file) For each single-page PDF: > DANewPage (add to output file) > DAOpenFile (input file) > DACapturePage (from input file) > DANewPage (in output file) > DADrawCapturedPage (on output file) > DACloseFile (input file) > DAClose File (output file) I haven't actually tried this yet--it seems like it would work, but it also seems a bit clunky. So, is there a better way? |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Eric!
You can live without the da-functions, too. After each add you can do a "free" and then a new "create". Please keep in mind "NewDocument" means always automatically "NewPage" - so if you're doing "NowDocument" and "NewPage" you have a pad with two pages. On this page you'll find code samples directly from Debenu: http://www.quickpdflibrary.com/samples/index.php Cheers, Ingo |
|
![]() |
|
Eric24 ![]() Team Player ![]() ![]() Joined: 28 Jun 09 Location: Dallas, TX Status: Offline Points: 29 |
![]() ![]() ![]() ![]() ![]() |
Thanks for the quick reply!
Could you elaborate a bit on your comments? 1) When you say I can live without the DA functions, my purpose of using them was to minimize memory usage by creating the full output file (that contains all the pages) on disk only. Are you saying I can achieve this without using DA functions? 2) Maybe this is what you're referring to by "free then a new create", but please explain exactly what I'm freeing and creating (and exactly what functions I should be calling). 3) I did find the C# sample for doing this, but since it appears to be doing everything in memory, I didn't think it would work for me. Maybe there is something I'm not understanding about the "high level" functions--would using them not result in a "completely in-memory" version of my output PDF? 4) Finally, on a related note, is it possible to "mix" DA and non-DA functions? In other words, could I do a non-DA CapturePage and use the CaptureID in a call to DADrawCapturedPage? (I believe the answer is no, but just making sure). Edited by Eric24 - 29 Jun 09 at 4:44AM |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Eric!
The big difference between DA- and not DA-functions is that the Not-DA-functions load the complete pdf-document into memory before working on it. If you want to add few png-files and if your final pdf-document won't be larger than (let us say) 20-25 mb then it's not necessary to use the DA-functions.
With create and free i mean this functions:
PDFLibrary := TQuickPDF0714.Create;
PDFLibrary.Free; Again:
If you need any code-samples have a look here:
For your very first start have a look here:
Please don't mix DA- and Non-DA-functions! Not understandable situations can be the result. It should be clear that you can't work with functions which need a loaded pdf-document on a "DA-loaded document";-) So my answer to your point 4 is "No".
You should now first start to try something then a lot of things will be clearer for you.
Cheers, Ingo
|
|
![]() |
|
Rowan ![]() Moderator Group ![]() ![]() Joined: 10 Jan 09 Status: Offline Points: 398 |
![]() ![]() ![]() ![]() ![]() |
As Ingo mentioned, the DA and non-DA functions will not work together at all. You could try using the MergeFileListFast function if you wanted to try to do this in memory, however, if you're dealing with PDFs over 50-100 MB, this can be quite slow due to the nature of PDFs.
As for merging using the direct access functions, the method you've outlined should do the trick and I can't see any obvious way to optimize it further to make it less clunky. I have however added a new feature request to our database for a simpler way to merge files using the direct access functionality, but there's no ETA for this feature at the moment. Cheers, - Rowan.
|
|
![]() |
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