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?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #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

    #27374

    setHtmlTemplate() 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)

    #27375

    Thank you for your help. I will try your suggestions!

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.