HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › General questions / FAQ › will setHtmlTemplate() work in the trial version of PD4ML?
- This topic has 2 replies, 2 voices, and was last updated Jul 14, 2009
21:51:59 byjean.
-
AuthorPosts
-
July 14, 2009 at 17:59#26223
I 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:
[language=java:3fb0dy6f]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(“
“);
str.append(“Name: John Doe”);
str.append(““);
str.append(“DOCUMENT PRINT TEST”);
str.append(““);
str.append(“07/09/09”);
str.append(““);
str.append(““);return str.toString();
}[/language:3fb0dy6f]
Am I using setHtmlTemplate() incorrectly?thank you for your help.
jean
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:
[language=java:3j8ekjgx]java -jar pd4ml_demo.jar[/language:3j8ekjgx]
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)July 14, 2009 at 21:51#27375Thank you for your help. I will try your suggestions!
-
AuthorPosts
The forum ‘General questions / FAQ’ is closed to new topics and replies.
