Forum Replies Created
-
AuthorPosts
-
in reply to: Rendering images 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
<base>setting of the doc). If the image URL is defined like“/WebAppName/path/to/image.gif”
PD4ML requires, that you pass current servlet context to it with
useServletContext(ServletContext ctx)
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:
- 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
in reply to: Rendering images July 6, 2009 at 18:10#27357Ok, 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.
in reply to: Rendering images July 6, 2009 at 18:19in reply to: Rendering images July 10, 2009 at 17:11#27359Yes 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?
in reply to: General questions / FAQ July 14, 2009 at 17:59#26223I am attempting to perform a proof of concept using the trial version of PD4ML and java (no jsp). I want to be able to display multiple tables in the header and footer. When I create a string containing html table tags and use setHtmlTemplate(htmlstring) to place this string in the header the rendered HTML does not appear in the resulting PDF document. I am wondering what I am doing wrong.
My test code looks like this:
private void generatePDF(String inputHTMLFileName, File outputPDFFile, Dimension format, String fontsDir, String headerBody) throws Exception { java.io.FileOutputStream fos = new java.io.FileOutputStream(outputPDFFile); PD4ML pd4ml = new PD4ML(); pd4ml.setPageInsets(new Insets(20, 10, 10, 10)); pd4ml.setHtmlWidth(950); pd4ml.enableImgSplit(false); if ( fontsDir != null && fontsDir.length() > 0 ) { pd4ml.useTTF( fontsDir, true ); } PD4PageMark header = new PD4PageMark(); header.setAreaHeight( 20 ); header.setHtmlTemplate(populateHTMLHeaderFields()); pd4ml.setPageHeader( header ); pd4ml.render("file:" + inputHTMLFileName, fos); } private String populateHTMLHeaderFields() { StringBuffer str = new StringBuffer(); str.append("<table width=100%><tr><td width=30%>"); str.append("Name: John Doe"); str.append("</td><td width=35%>"); str.append("DOCUMENT PRINT TEST"); str.append("</td><td width=35%>"); str.append("07/09/09"); str.append("</td></tr></table>"); str.append("</BODY></HTML>"); return str.toString(); }
Am I using setHtmlTemplate() incorrectly?thank you for your help.
jean
in reply to: will setHtmlTemplate() work in the trial version of PD4ML? July 14, 2009 at 21:13#27374setHtmlTemplate() works in the trial versions. But it is a feature of PD4ML Pro, so first make sure you use Pro version of the software.
The simpliest way to check that is to run PD4ML in GUI mode and to open About dialog:
java -jar pd4ml_demo.jar
Also try to set header.setAreaHeight( -1 ); to autocompute the header height. You use 20pt height, which may be too low for the header table (only table margins fit the space; the content is clipped)in reply to: will setHtmlTemplate() work in the trial version of PD4ML? July 14, 2009 at 21:51#27375Thank you for your help. I will try your suggestions!
in reply to: PD4ML Tips & Tricks July 14, 2009 at 21:54#26224Hi,
I am using the latest java version of pd4ml and noticed that utf-8 encoded html pages with Chinese characters are not converted properly. The chinese characters appear like ??? in the generated pdf. Please let me know how to fix it.
PS: I am using command line execution on unix
Thanks!
in reply to: HTML/CSS rendering issues July 15, 2009 at 22:11#26225Hi
Is it possible to ensure that a div dose not get split over pages in the same way as a
<tr> with style="page-break-inside:avoid;" so <div style="page-break-inside:avoid;">
??would be very useful to know..
many thanks
in reply to: Troubleshooting July 16, 2009 at 11:12#26226Hello,
I’m currently evaluating pd4ml. I’ve a problem using the method PD4ML.setDynamicParams(). As this works well for parameters defined in the page body, dynamic parameters in the header don’t get replaced by the value stored in the map given to the setDynamicParams() method.
Here is a code fragment showing how I proceeded:
final PD4ML pdfCreator = new PD4ML(); final Map<String, String> dynamic = new HashMap<String, String>(); dynamic.put("variable","value"); pdfCreator.setDynamicParams(dynamic); final PD4PageMark header = new PD4PageMark(); //$[variable] is contained in "someHTML", e.g. <html><head></head><body>$[variable]</body></html> header.setHtmlTemplate(someHTML); header.setAreaHeight(-1); pdfCreator.setPageHeader(header); //if $[variable] is contained in the HTML code returned by url, its value gets replaced as expected pdfCreator.render(url, outputStream);
I use the current version of pd4ml (3.5.1b1). Am I doing anything wrong?Regards,
Matthiasin reply to: Dynamic parameters July 16, 2009 at 11:57#27385Yes, you are right. PD4ML does not substitute placeholders for headers/footers defined that way (however it works for inline headers and footers, i.e.
<pd4ml:page.header>)It is quite a trivial task to replace the placeholders in someHTML before it passed to PD4ML. For example, with String.replaceAll() Java API call.
If the workaround, for some reasons, is not acceptable by you, or if you want to keep the placeholder replacement mechanism of PDF generating module in your application consistent, we could add the feature to the forthcomming release.
in reply to: Conversion issue with Chinese characters July 16, 2009 at 12:21#27376??? characters instead of CJK glyphs may appear in two cases:
- You use non-Pro version of PD4ML
- TTF embedding is not switched on or not correctly configured. See: pd4ml-html-css-pdf-tips-tricks-f7/ttf-embedding-t42.html
in reply to: Dynamic parameters July 16, 2009 at 13:50#27386Thanks a lot for your quick response! This restriction won’t be a showstopper for us as there’s the comfortable workaround you’ve mentioned. (We’ve already thought of that workaorund before posting the question to the forum: Our intention was prevent “to reinvent the wheel”, that means use the given method if possible.)
Regards,
Matthiasin reply to: Troubleshooting July 16, 2009 at 16:02#26227Hello,
we have a problem in conjunction with the definition of stylesheets. Currently we set the stylesheet file via call to PD4ML.addStyle(), e.g.
pdfCreator.addStyle(someUrl, true);We define the page header using the method PD4ML.setPageHeader(somePD4PageMark).
We use PD4PageMark.setHTMLTemplate(someHTML) to set the HTML content.
First of all: Does “someHTML” have to be valid HTML, that means does it have to contain tags like “
<html>" or "<body>”?After that, we render the page using the method PD4ML.render(someURL, someStream);
(Again: Does the HTML returned by “someURL” have to be valid HTML?)
The problem concerning the stylesheet definition now is as follows:
The stylesheet file contains the following style definition:body {
background-color: white;
font-family: Arial,Helvetica,Geneva,sans-serif;
}The resulting pdf document only contains the header, but not the content retrieved by call to PD4ML.render(). (We found out that the content somehow gets painted over by the background-color.)
After removing “background-color: white” out of this style definition, everthing works fine. As our customers can define their own styles for their printings, we cannot assure that a customers won’t create a stylesheet we ran in problems with. Could you please instruct us how to prevent that issue?Regards,
Matthiasin reply to: HTML-to-Image conversion with PD4ML July 16, 2009 at 19:04#27258We are looking to use this feature however we would like some additional documentation on what the parameters are and how we can make use of them.
I have only seen this feature referenced in release notes and this forum. There is no mention in the API or Reference manual that I have found.Thanks , James
-
AuthorPosts
