Print Page | Close Window

Lessons learned loading TIF images

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=768
Printed Date: 12 May 24 at 7:43AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Lessons learned loading TIF images
Posted By: JimCanuck
Subject: Lessons learned loading TIF images
Date Posted: 16 Aug 07 at 2:31PM
All:
 
After some great help (thanks Marian!) learning the basics of converting TIF images to PDF documents, I discovered a few problems and tricks along the way that I will now share.  I'm working in VB6.
 
After initially getting over the hump of learning that you must not only use
 
 QP.AddImageFromFile(tifFileName, 0)   but also  QP.DrawImage(left, top, width, height....)    as well  (image that...),  and discovering the right co-ordinate system, so that I acutally drew the image ON the page....
 
I found the images I was adding were not appearing correctly in the PDF document.
 
I was adding TIF images, 8 bit color,  LZW compression.  They were appearing in the PDF as grey scale. The white background was black, the colors were various grey scale.  Yuuch!
 
I discovered that the TIF images had to be 24 bit color before they would appear correctly.  Problem Solved. Well, not really.  This lead to another problem. 
 
The AddImageFromFile() call was very slow!! The images I was using for testing was ~ 1000 x 1000 dots, 125 DPI, roughly one letter or A4 page. Nothing huge. 150k on disk.  The call was taking 5-10 seconds to complete!
 
8 bit files were much faster. under 1 second. But I could not use them due to the color issue
 
I even tried using variant arrays to initially store the image (my image handling control has this function), then use qp.AddImageFromVariant() in an attempt to speed up the call. It was actually slightly slower if anything....
 
So the trial and error continued.  I tried other formats. JPEG files (native 24bit) did not work at all, I would get errors opening the pdf'.s  "Insufficient data for an image" and the files were obviously too small (2k) suggesting correct conversion in the file).
 
In the end, bitmap (bmp) files were the answer. The same image, as 24 bit BMP files, take under 1 second to load using AddImageFromFile()
 
Hope this helps someone in the future. After all the questions regarding image handling, I'm especially happy to have this working and to share what I have learned.
 
Cheers!
 
Jim



Replies:
Posted By: Ingo
Date Posted: 16 Aug 07 at 5:21PM
Hi Jim!
Thanks for your detailed help!
Postings like yours are quite seldom here.
Welcome and best regards,
Ingo



Posted By: Michel_K17
Date Posted: 25 Aug 07 at 10:10AM
Wow... good info: thank you for sharing. Sounds like QuickPDF has a lot of image handling issues. I imagine then that the best bet is to use a separate image library in VB6 to import a TIF/JPG etc. , convert to BMP either in memory, or to a file, and then import into the PDF?

What a shame.



-------------
Michel


Posted By: Francesco
Date Posted: 29 Sep 07 at 8:38AM

Is not a good idea to export TIF/JPG images as BMP and then import this in the PDF as in this case you will loose original compression !

For example, if you have a TIF file with an A4 bitonal page compressed as G4, and the files size is 50 Kb, if you will import directly from TIF then the PDF created will have about the same size, while if you export to BMP then the PDF created will be about 1000 Kb. Also if you enable the image compression, the file will be compressed using "deflate" algo (not G4) and the image will still be 200/300 kb...
 
Francesco


Posted By: StarSteve
Date Posted: 26 Nov 07 at 8:30PM

Hi All,

hmm... very strange this image (esp. TIF/JPEG) problems weren't in version 4.41.1.1 (21.12.2004), but indeed in version 5.22.0.145 (01.03.2007). Also, the SaveImageToFile doesn't work with TIF/JPEG (anymore)
 
see sample (in v5.22 all corrupted, missing images are 24bit JPEG):
v.4.41= NO PROB: http://astroworld.net/DEV/samples/v41.pdf - http://astroworld.net/DEV/samples/v41.pdf
v.5.22= BIG PROB: http://astroworld.net/DEV/samples/v52.pdf - http://astroworld.net/DEV/samples/v52.pdf
 
I guess, accidently something was changed in the code to no good
Q2Proggers: any idea ?
 
please solve, if possible...
 
cu Stefan


Posted By: StarSteve
Date Posted: 26 Nov 07 at 9:21PM

some add.notes to the above :

v4.41 (24.12.2004) = OK
v4.42 (01.04.2005) = OK
v5.13 (08.01.2006) = OK
v5.14 (11.02.2006) = OK
v5.20 RC1 (20.11.2006) = OK
v5.20 RC2 (05.12.2006) = OK
v5.21 (28.12.2006) = OK
v5.22 (01.03.2007) = ERROR
 
since the s.c for v5.22 wasn't published yet, I can't check/review it myself  
but Michel could you plz do
 
cheers Stefan


Posted By: Michel_K17
Date Posted: 27 Nov 07 at 12:28AM
Sorry. v5.22 Source code is in the hands of Marian who authored the changes and he is not making it available. We have discussed this at length and part of the problem is that Marian cannot work on the library for free. Nonetheless, I do know that Marian is pretty flexible and willing to help. Try sending him an e-mail at support[at]quickpdf[dot]org.  Maybe he will be able to take a look and perhaps fix.

Cheers!


-------------
Michel


Posted By: StarSteve
Date Posted: 27 Nov 07 at 9:03AM
thx mate :)
I 'll do so asap - cheers Stefan



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