Print Page | Close Window

DrawImage Settings and Memory Issue

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=1341
Printed Date: 22 Nov 24 at 5:54PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: DrawImage Settings and Memory Issue
Posted By: eddy2099
Subject: DrawImage Settings and Memory Issue
Date Posted: 08 Feb 10 at 8:23AM
I am currently evaluating v7.17 and my main use of the library would be to merge images into a single pdf file.
 
1) DrawImage

I was reading up on the DrawImage method which reads
 
function TQuickPDF0717.DrawImage(Left, Top, Width, 
  Height: Double): Integer;
 
 and try the following line
 
QP.DrawImage(0,0,lWidth,IHeight);
 
It however does not draw anything but blank pages.

I found the Delphi_DCU_Convert_Image_to_PDF example and found the implementation as
 
QP.DrawImage(0, lHeight, lWidth, lHeight);
 
and that did the trick as the image filled the whole page.
 
I am actually confused here, shouldn't the 'Top' parameter refers to the top most pixel in which to place the image and not the bottom most pixel to place the image.
 
Is there an error to the component implementation or the documentation in wrong in this or I am just misinterpreting this.
 
2) Memory Issue

The second issue I have is that I would need to add some 200 odd images to a single PDF file and for my test of about 180 jpeg images, the memory usage keeps ballooning each time I add an image. Is there a way to get the library to write to file midway,  I did use the 'SetTempFile' and 'SetTempPath' but it looks like they were not being used. With 180 images, it seems to work fine as the memory usage for the program was about 600mb.

However when I added some 500 images, when it hits about 1.8gb memory usage, it stopped accepting images and reject them. Also the PDF file generated was about 6kb which was apparently in error.  Is there anything I can do to prevent this from happening ?
 
Sorry but I am new to this library. However, I must say that it is quite fast in adding the images. Overall the output looks good when it worked.




Replies:
Posted By: Shotgun Tom
Date Posted: 08 Feb 10 at 5:12PM
Hi:
 
By default, a PDF's document origin is at the bottom left of the page.  You can change this using the QuickPDF Library.  See the "Set Origin" method.  If, for example, you want to set the origin to top left then the method would be QP.SetOrigin(1).  Now when you use Drawing commands it starts at the top left instead of the bottom left of the document.
 
Tom


Posted By: Ingo
Date Posted: 08 Feb 10 at 8:27PM
Hi Eddy!

The newest version shouldn't have problems with memory.
But if it's like you told us:
Try to make a "free" after a fix number of images and then a new "create" with the next images and so on... all appending to the first pdf-part.
Long time ago i've done it this way to avoid memory-problems.

Cheers, Ingo



Posted By: eddy2099
Date Posted: 09 Feb 10 at 1:13AM
Hi Tom and Ingo,

Thank you very much for answering my questions.

I've looked at the DAAppendFile but apparently that was the wrong direction to take since it did not really work in my case. I supposed that I could create several PDF files, perhaps 100 images per file then use MergeFileList to combine them all.

If there is any suggestions, do feel free to drop them here ;) Thanks again, you are certainly a very helpful bunch.


Posted By: Ingo
Date Posted: 09 Feb 10 at 6:11AM
Hi Eddy!

Here you can see what i mean with "a free from time to time":
http://www.quickpdf.org/forum/creating-large-files-very-slow_topic813_post3919.html?KW=QP.Free#3919
What's your problem with DAAppendFile? Please keep in mind that it's not possible to mix the DA-functions with the non-DA-functions!
Try the search-functionality (advanced) above with "QP.Merge"... you'll find many samples.

Cheers and welcome here, Ingo
 


Posted By: eddy2099
Date Posted: 10 Feb 10 at 1:19AM
Thanks Ingo.

Sorry I am new at this. When I tried to do the DAFileAppend method, it does seems that it does not work with the DrawImage method. I read that there is a limit to what Direct Access methods and functions can do.

As such, probably my option would be to probably create say PDF of about 100 pictures each then merge them once all the 'smaller' pdfs are created.


Posted By: Ingo
Date Posted: 11 Feb 10 at 6:14AM
"...
When I tried to do the DAFileAppend method, it does seems that it does not work with the DrawImage method.
..."

Like i've written: Don't mix DA with non-DA ...

Cheers, Ingo



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