PDF Space Export fails due to "Cannot read property"
Problem
Generating a space PDF export fails with this error:
A series of different warnings appear in the atlassian-confluence.log to end with an error:
2012-08-10 18:02:13,734 WARN [Long running task: PDF Space Export] [lobobrowser.html.domimpl.HTMLScriptElementImpl] processScript Javascript error at bundle://29.0:1/sh/src/shCore.js:32: ReferenceError: "XRegExp" is not defined. (bundle://29.0:1/sh/src/shCore.js#32)
-- url: /spaces/flyingpdf/doflyingpdf.action | userName: alex | referer: http://localhost:6429/spaces/flyingpdf/flyingpdf.action?key=ds | action: doflyingpdf
org.mozilla.javascript.EcmaError: ReferenceError: "XRegExp" is not defined. (bundle://29.0:1/sh/src/shCore.js#32)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219)
...
2012-08-10 18:02:13,770 WARN [Long running task: PDF Space Export] [lobobrowser.html.domimpl.HTMLScriptElementImpl] processScript Javascript error at bundle://29.0:1/sh/scripts/shBrushJava.js:50: TypeError: Cannot read property "Highlighter" from undefined (bundle://29.0:1/sh/scripts/shBrushJava.js#50)
-- url: /spaces/flyingpdf/doflyingpdf.action | userName: alex | referer: http://localhost:6429/spaces/flyingpdf/flyingpdf.action?key=ds | action: doflyingpdf
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "Highlighter" from undefined (bundle://29.0:1/sh/scripts/shBrushJava.js#50)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219)
...
2012-08-10 18:02:13,770 WARN [Long running task: PDF Space Export] [lobobrowser.html.domimpl.HTMLScriptElementImpl] processScript Javascript error at bundle://29.0:1/template.html:2: TypeError: Cannot read property "config" from undefined (bundle://29.0:1/template.html#2)
-- url: /spaces/flyingpdf/doflyingpdf.action | userName: alex | referer: http://localhost:6429/spaces/flyingpdf/flyingpdf.action?key=ds | action: doflyingpdf
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "config" from undefined (bundle://29.0:1/template.html#2)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219)
...
2012-08-10 18:02:15,325 ERROR [Long running task: PDF Space Export] [core.task.longrunning.AbstractLongRunningTask] doInTransactionWithoutResult Error during PDF export
-- url: /spaces/flyingpdf/doflyingpdf.action | userName: alex | referer: http://localhost:6429/spaces/flyingpdf/flyingpdf.action?key=ds | action: doflyingpdf
com.atlassian.confluence.importexport.ImportExportException: Exception thrown while rendering the page 'no title found' to the PDF document /opt/atlassian/Confluence/data/confluence-4.2.12/temp/pdfexport-20120810-100812-1802-17/ds-100812-1802-18.pdf
at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:110)
at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerPdfExporterService.createPdfForSpace(FlyingSaucerPdfExporterService.java:58)
at com.atlassian.confluence.extra.flyingpdf.PdfExportLongRunningTask$1.doInTransactionWithoutResult(PdfExportLongRunningTask.java:70)
...
Diagnosis
In the section PDF Space Export Header or PDF Space Export Header there is a div
tag with the form:
<div ... />
Please note that this only happens for Space PDF export, page XML export can still work normally.
Cause
In the PDF Layout for the space (or the global one if non is specified) there is a div
tag without any content:
<div ... />
Workaround
Replace your tag without content by an opening and a closing tag:
<div ...></div>