Exporting page or space to PDF fails and causes high load or OutOfMemory Error

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

  • When exporting a page or space to PDF, it doesn't succeed and causes a high load on Confluence until it triggers an OutOfMemory Error.

  • When exporting a single page, the process hangs and ultimately fails. The "System Error" page is displayed and the following appears in the atlassian-confluence.log:

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2012-04-19 17:22:06,698 ERROR [http-8080-3] [[Standalone].[localhost].[/confluence].[action]] log Servlet.service() for servlet action threw exception java.lang.OutOfMemoryError: Java heap space at java.util.LinkedList.addBefore(LinkedList.java:778) at java.util.LinkedList.add(LinkedList.java:198) at org.xhtmlrenderer.css.newmatch.CascadedStyle.addProperties(CascadedStyle.java:148) at org.xhtmlrenderer.css.newmatch.CascadedStyle.<init>(CascadedStyle.java:135) at org.xhtmlrenderer.css.newmatch.Matcher.getPageCascadedStyle(Matcher.java:121) at org.xhtmlrenderer.context.StyleReference.getPageStyle(StyleReference.java:203) at org.xhtmlrenderer.layout.Layer.createPageBox(Layer.java:794) at org.xhtmlrenderer.layout.Layer.addPage(Layer.java:764) at org.xhtmlrenderer.layout.Layer.addPagesUntilPosition(Layer.java:875) at org.xhtmlrenderer.layout.Layer.getPage(Layer.java:861) at org.xhtmlrenderer.layout.Layer.getFirstPage(Layer.java:805) at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:774) at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:735) at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:209) at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:92) at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:38) at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerPdfExporterService.createPdfForPage(FlyingSaucerPdfExporterService.java:78) at com.atlassian.confluence.extra.flyingpdf.ExportPageAsPdfAction.execute(ExportPageAsPdfAction.java:28) ....
  • When exporting a space to PDF, it becomes stuck at Begin conversion of intermediate HTML to PDF:

    (Auto-migrated image: description temporarily unavailable)

    The following appears in the atlassian-confluence.log:

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2012-04-19 17:02:40,878 ERROR [Long running task: PDF Space Export] [content.render.xhtml.DefaultRenderer] render Error rendering content for view: RuntimeException occurred while performing an XHTML storage transformation (null) -- referer: http://localhost:8080/confluence/spaces/flyingpdf/flyingpdf.action?key=SBX | url: /confluence/spaces/flyingpdf/doflyingpdf.action | userName: admin | action: doflyingpdf com.atlassian.confluence.content.render.xhtml.XhtmlException: RuntimeException occurred while performing an XHTML storage transformation (null) at com.atlassian.confluence.content.render.xhtml.storage.StorageXhtmlTransformer.transform(StorageXhtmlTransformer.java:60) at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:41) at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:53) at com.atlassian.confluence.content.render.xhtml.DefaultRenderer.render(DefaultRenderer.java:63) at com.atlassian.confluence.content.render.xhtml.DefaultRenderer.render(DefaultRenderer.java:51) at com.atlassian.confluence.extra.flyingpdf.html.RenderedXhtmlBuilder.renderToHtml(RenderedXhtmlBuilder.java:377) at com.atlassian.confluence.extra.flyingpdf.html.RenderedXhtmlBuilder.renderContentTreeNodes(RenderedXhtmlBuilder.java:346) at com.atlassian.confluence.extra.flyingpdf.html.RenderedXhtmlBuilder.buildHtml(RenderedXhtmlBuilder.java:134) at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerPdfExporterService.createPdfForSpace(FlyingSaucerPdfExporterService.java:50) at com.atlassian.confluence.extra.flyingpdf.PdfExportLongRunningTask$1.doInTransactionWithoutResult(PdfExportLongRunningTask.java:70) at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128) at com.atlassian.confluence.extra.flyingpdf.PdfExportLongRunningTask.runInternal(PdfExportLongRunningTask.java:52) at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:21) at com.atlassian.confluence.util.longrunning.ManagedTask.run(ManagedTask.java:35) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.NullPointerException at com.atlassian.confluence.content.render.xhtml.editor.macro.DefaultPlaceholderUrlFactory.getUrlForErrorPlaceholder(DefaultPlaceholderUrlFactory.java:73) at com.atlassian.confluence.content.render.xhtml.transformers.TransformErrorToHtmlPlaceholder.handle(TransformErrorToHtmlPlaceholder.java:54) at com.atlassian.confluence.content.render.xhtml.transformers.DefaultFragmentTransformer.transform(DefaultFragmentTransformer.java:124) at com.atlassian.confluence.content.render.xhtml.storage.StorageXhtmlTransformer.transform(StorageXhtmlTransformer.java:43) ... 20 more

Cause

This is normally caused by an incompatible or problematic PDF stylesheet. Particularly the following CSS, if the value for margin is bigger than 5in:

1 2 3 4 @page { margin: 5.5in; }

This bug is being tracked at CONFSERVER-25278 - Page margin CSS in PDF Stylesheet can OOME and cause high load on Confluence during space export to pdf.

Workaround

Remove or reset the PDF stylesheets. You can base your customizations on the default CSS rules of the PDF stylesheet called confluencedefaultpdf.css. You can copy it from a backup or another Confluence install. If you can’t locate the file at all, please contact Atlassian support. See also our documentation

Any rule defined in that stylesheet can be customised.

Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.