Print Page | Close Window

AddImageFromFile and multipage TIF

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=649
Printed Date: 16 May 24 at 1:52PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: AddImageFromFile and multipage TIF
Posted By: peteratoce
Subject: AddImageFromFile and multipage TIF
Date Posted: 23 Feb 07 at 2:53AM
I am importing scanned documents, that is, multipage TIFs that each contain a large number of pages, into PDF. The TIFs are A4, 600 dpi. I am using QuickPDF V 5.21 (the Active X variant), the program is written in VB.NET (2003).
 
My program basically works, in that a PDF with the intended number of pages is created that look o.k. at first glance.
 
When I looked further I noticed a very strange thing, though: After about 60 pages the content of the remaining pages did not change any more until the end of the 100 page PDF. That means that

AddImageFromFile(InFile, i + 1)

did not add new images for i > 41, even though the return value never became 0! 
 
Have anyone of you noticed such unexpected behaviour of the AddImageFromFile function before?
 
Peter



Replies:
Posted By: ixm7
Date Posted: 24 Feb 07 at 1:12PM
In my experience, you can't rely on the return value. It is NOT an indication there are no more pages in the TIFF file.

How many ACTUAL pages are in your multi-page TIFF file?

Cheers,
- Ido


Posted By: peteratoce
Date Posted: 25 Feb 07 at 3:53AM
Ido, I would not expect an indication of the actual pages in the TIF file from that function call. In fact, I retrieved that information through GDI+ before starting with QuickPDF processing.
 
I found another problem with images and the QuickPDF library:
When you try to do the inverse processing, that is, write TIF images from PDF to file, you need first to determine the number of images available. For this there exists function FindImages(). 
 
I had created a PDF from my 100 pages TIF with the help of Acrobat (BTW, the TIF has 1200 dpi, I falsely reported 600 dpi instead in my original post). My program to extract the images crashed  in function FindImages:
System.Runtime.InteropServices.COMException (0x8000FFFF): Out of memory while expanding memory stream
   at iSED.IQuickPDF.FindImages()
 
That gives the impression that the library attempts to read all existing images into memory while finding out the total number of images!
 
Well, I think I will abandon the idea to use QuickPDF for the handling of a large number of images per file (sigh).
 
Peter


Posted By: Ingo
Date Posted: 25 Feb 07 at 6:23AM
Hi Peter!
FindImage is buggy since a long time.
I'm doing the ImageCount directly in the pdf-source searching and counting the relevant image-objects.
Best regards,
Ingo


Posted By: ixm7
Date Posted: 25 Feb 07 at 7:38AM
QP.GetImagePageCount(TIFF_File) gives you the number of images inside the TIFF file. Then, loop through and bring each page in. Works fine for me.

Peter, if you email to me (ido at milletsoftware.com) the 100-page TIFF file, I can test and let you know if my routine works on it.

Cheers,
- Ido


Posted By: peteratoce
Date Posted: 04 Mar 07 at 11:36AM
Hi Ingo,
how do you access the image objects after you found them directly? My aim is to export them to a TIF file. And, to be honest, I am not too keen on delving down into the PDF itself, that's why I like to use libraries like QuickPDF...
 
Peter


Posted By: ixm7
Date Posted: 04 Mar 07 at 11:46AM
Peter sent me a 30MB TIFF file and I tested adding the images to a PDF file using code that works very well with other (smaller) multi-page TIFF files.

I can confirm the problem he's reporting. After more than 30 minutes, the process was still churning at close to 100% CPU utilization.

Peter, I suggest you contact Marian and offer to sponsor a fix for this issue. I've sponsored Marian for one enhancement to the library and he came through with a nice fix within 1 week.

Cheers,
- Ido


Posted By: Ingo
Date Posted: 04 Mar 07 at 2:08PM
"... I am not too keen on delving down into the PDF itself, that's why I like to use libraries like QuickPDF..."

Hi Peter!

To be honest ... me too ;-)
In my case i only want to detect that there are images - i don't want to do anything with them.

Best regards,
Ingo



Posted By: Ingo
Date Posted: 04 Mar 07 at 2:19PM
Hi!

Extracting textcontent from very big files with many pages i've made similar  experiences... The extracting seems to stop  and doesn't come to an end and all the time i've got 100% cpu utilisation.

If i've  many pages to extract now i free the instance after a specified pagecount, create a new instance starting with the last page+1 ... I#ve made very good experiences with it!

With GetImagePageCount you know the page count and now you can make several runs with AddImageFromFile.

I really think this could work for you.
 
Best regards,
Ingo




Posted By: peteratoce
Date Posted: 06 Mar 07 at 4:18AM
Ingo, I tried to process packages of only 10 pages, each with a new instance. The error occured anyway, and at the self same page of the input TIF.
 
So, there has to be something amiss with the design of function AddImageFromFile. I suspect that the function call tries to read all pages into memory until it finally arrives at the one that was actually asked for, instead of simply determining the offset and range of the image data for the desired page and grab that only.
 
Peter  


Posted By: marian_pascalau
Date Posted: 06 Mar 07 at 5:14AM
Peter,
send a detail bug report to support(at)quickpdf.org . We will check this problem and confirm eventualy what you are saying.
 
Please send the TIFF file and a small code snippet.
 
Best regards, Marian


Posted By: marian_pascalau
Date Posted: 11 Apr 07 at 10:51AM

Hi Peter,

sorry for delay but I had some other bugs pending. Peter I have checked your problem. The problem you have is caused by a bad QuickPDF implementation and a very bad behaviour of the default Delphi Memory manager (which creates a very bad memory fragmentation when working with large pointers).

 

This means that when you compile the ActiveX version of QuickPDF library the normal way with Delphi then you will still get this error. But when compiled with the FastMM memory manager for Delphi it should work without problems (http://sourceforge.net/projects/fastmm/).

 

Best regards, Marian




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