- This topic has 5 replies, 2 voices, and was last updated Jul 16, 2010
21:39:22 by PD4ML.
July 6, 2009 at 17:08#26220
I am facing a problem when the HTML to export contains different images, I mean, if the HTML contains jpg, png or gif files. Some of those images are not exported correctly in the PDF, but not always the same images fails.
Is this an unfixed issue?
Thanks.July 6, 2009 at 17:26#27356
Image embedding is one of the major functions of PD4ML, which is available since the first version of the software. So normally for GIF, JPEG and PNG it should be no problems.
A possible reason of the issue is image addressing: you need to make sure, that image URLs are either fully-specified (include protocol, server, port), or the URLs are relative to the actual document location (or to
setting of the doc). If the image URL is defined like
PD4ML requires, that you pass current servlet context to it with
otherwise PD4ML has no chance to resolve the virtual path. (PD4ML JSP Taglib triggers the method implicitly)
If the above is not relevant for your particular case, please provide us with some more info:
July 6, 2009 at 18:10#27357
- PD4ML usage scenario: Java, JSP, PHP, etc…
- A sample of image reference
- PD4ML debug output for a case, when it cannot load an image ()you may switch the debug output on with pd4ml.enableDebugInfo() call
Ok, here are more details:
It is a Java application. JDK 1.4.
The process is writing the HTML in a path, then the HTML is read from the path to write the PDF in the same path. Ex:
File fz = new File(path+filename); //HTML to read
java.io.FileInputStream fis = new java.io.FileInputStream(fz);
InputStreamReader isr = new InputStreamReader( fis );
The images are being rendered correctly in most cases, but for example when I mix different kind of images (jpg, png, gif) in the HTML to export, then the last kind of image fails, when the ssame image in the same path can be rendered when it is the only image.
Here is the output of pd4ml on debug mode:
version: PD4ML 350 Pro (eval)
not yet in cache: file:C:\Fonts/pd4fonts.properties
‘serif’ is not in pd4fonts.properties file
reject TTF lookup for: ‘serif’
not yet in cache: file:C:\Fonts/times.ttf
read ‘times new roman’ from file:C:\Fonts/times.ttf
‘serif bold’ is not in pd4fonts.properties file
reject TTF lookup for: ‘serif bold’
not yet in cache: file:C:\Fonts/timesbd.ttf
read ‘times new roman bold’ from file:C:\Fonts/timesbd.ttf
not yet in cache: file:C:\Fonts/verdana.ttf
read ‘verdana’ from file:C:\Fonts/verdana.ttf
image not yet in cache: image not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24603dp254.jpg
not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24603dp254.jpg
image size: 116658
image not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif
not yet in cache: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif
resource http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif not found.
image http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif not found.
can not load image: http://xxx.xxx.x.xxx/mgr/attach/mmfiles/HT24604Control Panel Exhibit_1246900352801.gif
not yet in cache: file:C:\Fonts/cour.ttf
read ‘courier new’ from file:C:\Fonts/cour.ttf
done in 1817ms.
On the last lines there is a message that an image can not be loaded. But I copy that URL to the browser and the image can be reached with out problem.
If you need some more information please let me know. Thanks for the help.July 6, 2009 at 18:19#27358
I would suspect space characters in the image URLs.
Try to replace them with “%20”July 10, 2009 at 17:11#27359
Yes it was that, the spaces in the image path can not be resoved by pd4ml. Thanks
One more question, is there a way to autofit an image according to the pdf? I mean when I hace the img tag and it doesn’t specify a size, the image in the pdf is bigger or seems strange. So, is it possible or a way to autofit the image according to the PDF size?July 16, 2010 at 21:39#27360
If an tag has no height/width attributes, PD4ML uses the original pixel dimensions of the image.
If the image does not fit PDF page width, you need to adjust HTML-to-PDF scaling factor.
HTML->PDF conversion is performed in two steps: HTML rendering – it uses htmlWidth parameter (aka screenWidth in PD4ML JSP taglib) as virtual web browser frame width, and PDF output – it maps the htmlWidth to the horizontal width of choosen paper format.
If a particular image does not fit horizontally PDF page, that means, the image is wider than htmlWidth.
In the case you have two options:
- increase htmlWidth value (default is 640)
- scale down the image with height and width attributes of tag
The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.