PD4ML v4 Forums PD4ML v3 Archived Forums (Read Only) Troubleshooting OutOfMemory with page with many large images

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #27048

    Hi,

    With a long html page filled with photos, we get OutOfMemory. Raising the memory limit is not an option, it already very high, 8-12 GB. This is a server and we’re using the Java API.

    We need a way to let PD4ML render pages an images in a streaming fashion, more memory efficient. It cannot keep the entire rendered PDF, with all hi-res images, in memory.

    How can achieve this?

    <br /> private static PD4ML createPD4ML(int htmlWidth, Insets insetsMM, boolean landscape) throws FileNotFoundException {<br /> PD4ML pd4ml = new PD4ML();<br /> pd4ml.setPageInsetsMM(insetsMM);<br /> pd4ml.setHtmlWidth(htmlWidth);<br /> pd4ml.setPageSize(landscape ? pd4ml.changePageOrientation(PD4Constants.A4) : PD4Constants.A4);<br /> pd4ml.enableSmartTableBreaks(true);<br /> if (log.isDebugEnabled()) {<br /> pd4ml.enableDebugInfo();<br /> }<br /> pd4ml.useTTF("java:net/pingpong/tm/fonts", true);<br /> return pd4ml;<br /> }<br /> <br /> private static void createPDF(Person person, User user, Course course, HtmlResource htmlResource, File tmpPdf)<br /> throws FileNotFoundException, IOException {<br /> OutputStream outputStream = new FileOutputStream(tmpPdf);<br /> String html = resolvePathsAndFixHtml(person, user, htmlResource, course, true);<br /> try {<br /> DocumentManagerHandler.writePDFWithHeader(html, outputStream);<br />

    and in DocumentManagerHandler

    <br /> public static void writePDFWithHeader(String html, OutputStream outputStream) throws InvalidParameterException,<br /> IOException {<br /> PD4ML pd4ml = createPD4ML(DEFAULT_HTML_WIDTH, DEFAULT_INSETS_MM, false);<br /> pd4ml.setHtmlWidth(640);<br /> <br /> PD4PageMark header = new PD4PageMark();<br /> header.setTitleAlignment(PD4PageMark.RIGHT_ALIGN);<br /> header.setFont(new Font("sansserif", Font.PLAIN, 11));<br /> header.setAreaHeight(25);<br /> header.setTitleTemplate("${title}");<br /> pd4ml.setPageHeader(header);<br /> <br /> pd4ml.render(new StringReader(html), outputStream);<br /> }<br /> <br /> <br />

Viewing 1 post (of 1 total)

The forum ‘Troubleshooting’ is closed to new topics and replies.