Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27097

    Hello. I am trying to render html to pdf such that only a portion of the html content is rendered to pdf in dual column format. I want the output to look like this:

    Stuff before the dual-column text

    column1text column2text
    column1text column2text
    … …

    Here is a sample test:

    @Test<br /> public void dualColumnTest() throws Exception {<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.outputFormat(PD4ML.PDF);<br /> Insets insets = new Insets(10,10,10,10);<br /> pd4ml.setPageInsetsMM(insets);<br /> pd4ml.setHtmlWidth(800);<br /> pd4ml.adjustHtmlWidth();<br /> Map<String, String> m = new HashMap<String, String>();<br /> m.put(PD4Constants.PD4ML_MEDIA_TYPE_PRINT, "override");<br /> pd4ml.setDynamicParams(m);<br /> pd4ml.generateMulticolumn(2, 5, true);<br /> String content = "" +<br /> "<html><body>" +<br /> "<p>Stuff before the dual-column text</p>" +<br /> "<div usedualcolumn="true"><p>Lots of text to be placed in dual columns</p></div>" +<br /> "</body></html>";<br /> StringReader htmlInput = new StringReader(content);<br /> FileOutputStream pdfOutput = new FileOutputStream("c:/bb/foo.pdf");<br /> pd4ml.render(htmlInput, pdfOutput);<br /> }<br />

    But when I use generateMulticolumn(2,5,true) it sets it for the entire document. How can I select only a portion of the html content for dual column pdf? Thank you!

    #29925

    I should add that I also tried to get the html properly rendering in browser with dual column. I did it using this head meta:

    .printDualColumn {
    -moz-column-count: 2;
    -webkit-column-count: 2;
    column-count: 2;
    }

    And then I surrounded the content which needs dual column printing with:

    It renders correctly in dual column format in the browser from the html. But when I render the html to pdf using pd4ml it does not render in two column.

    @Test<br /> public void dualColumnTest2() throws Exception {<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.outputFormat(PD4ML.PDF);<br /> Insets insets = new Insets(10,10,10,10);<br /> pd4ml.setPageInsetsMM(insets);<br /> pd4ml.setHtmlWidth(800);<br /> pd4ml.adjustHtmlWidth();<br /> Map<String, String> m = new HashMap<String, String>();<br /> m.put(PD4Constants.PD4ML_MEDIA_TYPE_PRINT, "override");<br /> pd4ml.setDynamicParams(m);<br /> String content = "" +<br /> "<html>" +<br /> "<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css">" +<br /> "n.printDualColumn {n" +<br /> "tttt-moz-column-count: 2;n" +<br /> "tttt-webkit-column-count: 2;n" +<br /> "ttttcolumn-count: 2;n" +<br /> "ttt}n" +<br /> "</style></head>" +<br /> "<body>" +<br /> "<p>Stuff before the dual-column text</p>" +<br /> "<div class="printDualColumn">" +<br /> "Lots of text to be placed in dual columns" +<br /> "Lots of text to be placed in dual columns" +<br /> "Lots of text to be placed in dual columns" +<br /> "Lots of text to be placed in dual columns" +<br /> "</div>" +<br /> "</body></html>";<br /> StringReader htmlInput = new StringReader(content);<br /> FileOutputStream htmlInputFile = new FileOutputStream("c:/bb/foo2.html");<br /> htmlInputFile.write(content.getBytes());<br /> FileOutputStream pdfOutput = new FileOutputStream("c:/bb/foo2.pdf");<br /> pd4ml.render(htmlInput, pdfOutput);<br /> }

    Is there something I can do either in the css or in my java code?

    #29926

    For the time being there is only solution with tag. It is not exactly what you need, but in some cases it can be helpful.

    The tag tries to fit all given content into a specified box and automatically goes multicolumn when it is not possible with a single column.

    See pdf-generation-troubleshooting-f4/is-it-possible-to-toggle-multicolumn-from-page-to-page-t255.html

    Alternatively you may split your document to single- and multi-column parts, convert them separately and merge the resulting PDFs into a single doc (usin PD4ML’s PDF merge API).

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

The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.