HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › General questions / FAQ › BMP in BASE64 encoding
- This topic has 9 replies, 2 voices, and was last updated Dec 20, 2011
07:30:53 by meberle.
-
AuthorPosts
-
November 30, 2011 at 11:45#26635
My html file contains images in BMP format encoded as BASE64 (see example.zip).
I downloaded the demo version of PD4ML and run the Converter.class to do a quick test:
java -Xmx512m -cp pd4ml_demo.jar;ss_css2.jar;. Converter example.html example.pdf “” “”
The GIF image has been successfully converted in the PDF file. But the BMP file is missing (see example.pdf).
Does pd4ml support BMP files?
November 30, 2011 at 21:58#28724Does the BMP have transparency mask?
Could you please publish the image in its original form (as BMP file)?
Thank you!December 1, 2011 at 14:36#28725Please find the file signature.bmp in the attached signature.zip file.
December 2, 2011 at 20:00#28726Well, with your sample image we identified and fixed a bug in our code, related to 1-bit bitmap images.
However when I tried your original HTML sample with base64-encoded images, the BMP still failed to appear in the resulting PDF. Which is quite strange.
I have dumped base64-decoded image (“bad image”) and the second image you provided (“good image”). There is a difference in the file headers (the rests of the images are identical). See the attachment.
It is difficult to say if the “bad image” has been corrupted during base64 encoding or it is a species of BMP format, known only to Microsoft.
The impacted bytes are quite important:
Good image:
File type is :BM
Size of file is :4990
Size of bitmapinfoheader is :40
Width is :342
Height is :112
Planes is :1
BitCount is :1
Compression is :0
SizeImage is :4928
X-Pixels per meter is :0
Y-Pixels per meter is :0
Colors used are :2
Colors important are :2Bad image:
File type is :BM
Size of file is :4990
Size of bitmapinfoheader is :40
Width is :342
Height is :112
Planes is :1
BitCount is :1
Compression is :0
SizeImage is :0
X-Pixels per meter is :2834
Y-Pixels per meter is :2834
Colors used are :2
Colors important are :0It looks like MS IE repairs the “bad image” on-a-fly and displays it correctly. If you save the image from MS IE you’ll get an image byte-to-byte identical to the “good image”.
We would implement a workaround for such corrupted images, but it is not obvious how to obtain the missing “size of the raw bitmap data” value.
December 13, 2011 at 12:05#28727http://en.wikipedia.org/wiki/BMP_file_format explains how to calculate SizeImage. I will update our code and set this value. Would it be possible that you send me a test pd4ml package containing the bug fix for 1 bit bmp files?
December 14, 2011 at 17:13#28728I’ve just sent the version to your email box.
December 19, 2011 at 10:54#28729I tested your bux fix. But it seems there is still a problem.
Please find attached my example containing now BMP files which have set the ImageSize correctly (BMP file & BASE64 encoded).
Could you have a look at it again?
December 19, 2011 at 10:55#28730I tested your bux fix. But it seems there is still a problem.
Please find attached my example containing now BMP files which have set the ImageSize correctly.
Could you have a look at it again?
December 19, 2011 at 14:47#28731Yes, the images you provided are still not compatible with PD4ML.
I did the simple test again: opened your HTML in MS IE and saved the BMP as signature2.bmp and included it to example.html
Obviously MS IE again repaired format errors of your BMP. See attached.
I also compared signature.bmp and signature2.bmp. As I see 2 values “40” and “13” are swapped:
December 20, 2011 at 07:30#28732Many thanks!!! I didn’t take litte endian into account. Now it is working.
-
AuthorPosts
The forum ‘General questions / FAQ’ is closed to new topics and replies.