GeneralPdf Error: The document has no pages

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2018 09:04 PM
Hi - I'm using the GeneralPDF script include to generate PDF documents from ServiceNow (i.e. passing HTML to it).
I have this solution working perfectly in our own instance, and I'm now trying to do something similar (I'm using the same code, only modified for content) with another instance.
When I attempt to call the PDF generation though, I'm getting the following error in the System Log:
Root cause of JavaScriptException: com.itextpdf.text.ExceptionConverter : ExceptionConverter: java.io.IOException: The document has no pages.
I've found only one similar reference online where the user was passing HTML that defined 9 header columns, but only 5 data columns. I've checked the HTML that I'm feeding to GeneralPDF and I can see no such problems.
Does anyone have any other ideas on what this error could mean? Has anyone experienced this themselves?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 10:17 AM
Hello stevejarman
Please check your attachments, I had the similar problem where one of the image attachment in the template was missing. I found finally that one of the API that is trying to replace attachment by looking at the sys_attachment table before generating pdf was unable to do it. Since the attachment is not properly replaced at servicenow script level, it was causing error at the java pdf classes.
Thanks
Jophy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2018 05:22 PM
Is anyone else experiencing this issue or have any knowledge of it? I've never been able to resolve it. It's now broken in our own instance too, so I'm assuming ServiceNow have changed something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2018 06:57 PM
I had this issue recently. Found that the html tag <hr/> was causing it. There might be some other tags as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2018 09:27 PM
I ended up finding a solution, even though it used to work fine...
It turned out that any <img> tags directly referencing a URL were causing the failure. e.g.
<img src="http://something.com/something.jpg">
I had to end up base64 encoding the images directly into the sourcecode, and then things were fine. e.g.
var logoData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQ ... etc ... AAAC8CAYYII=";
var html = "";
html += "<img src='" + logoData + "' height='100' />";
// ETC ETC ETC