Print Page | Close Window

Creating large PDFs from PNG files

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=1120
Printed Date: 25 Apr 25 at 11:14AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Creating large PDFs from PNG files
Posted By: Eric24
Subject: Creating large PDFs from PNG files
Date 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?




Replies:
Posted By: Ingo
Date Posted: 28 Jun 09 at 10:23PM
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
 


Posted By: Eric24
Date Posted: 28 Jun 09 at 11:45PM
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).


Posted By: Ingo
Date Posted: 29 Jun 09 at 6:43AM
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:
http://www.quickpdflibrary.com/samples/index.php - http://www.quickpdflibrary.com/samples/index.php
For your very first start have a look here:
http://www.quickpdflibrary.com/help/getting-started.php - http://www.quickpdflibrary.com/help/getting-started.php
 
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 
 
 


Posted By: Rowan
Date Posted: 30 Jun 09 at 5:28AM
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.



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