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 - Creating large PDFs from PNG files
  FAQ FAQ  Forum Search   Register Register  Login Login

Creating large PDFs from PNG files

 Post Reply Post Reply
Author
Message
Eric24 View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Jun 09
Location: Dallas, TX
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eric24 Quote  Post ReplyReply Direct Link To This Post Topic: Creating large PDFs from PNG files
    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?

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3529
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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
 
Back to Top
Eric24 View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Jun 09
Location: Dallas, TX
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eric24 Quote  Post ReplyReply Direct Link To This Post 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).


Edited by Eric24 - 29 Jun 09 at 4:44AM
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3529
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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:
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 
 
 
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post 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.
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