Forum Bugs

Blank pdf generated when using webpack based single page application

ryan_fact
Good Day,

Running into a problem using princexml 11, where a blank pdf is being generated, but thankfully we have a few errors that might point to the cause.

error: unexpected token keyword("catch")
error: unexpected token keyword("default")
error: TypeError: value is not an object

I noticed that this is similar to the problem noted here:
https://www.princexml.com/forum/topic/2894/error-when-generating-a-pdf-with-the-javascript-flag

and the TypeError might be from various not supported javascript functions in prince.

Our application is webpack based, and is a single page application, so the javascript running into errors explains why nothing is being loaded into the page, although the page itself doesn't have these errors.

Any help will be appreciated.
hallvord
Hi Ryan, is it possible to let me test this - could you attach a file or post a URL? I could also try to re-produce the problem if you tell me a bit more about what libraries are used, but the best way to debug it is probably getting access to your code.

Announcement: repos for tests/utils

hallvord
Hi, I investigated a bit by using Prince to compile PDFs from some of the demos on https://github.com/ruanyf/webpack-demos . I got some of them working at least :)

Running this script as a compat layer with the --script argument made some of the demos render:

if(!Object.freeze)Object.freeze = function(o){return o;};

console.error = console.log;

window.postMessage = function(){};

var Set = function(){return {};};
var Map = function(){return [];};

Array.prototype.forEach = function(func) {
  for(var i = 0; i < this.length; i++) {
    func(this[i], i);
  }
}

window.HTMLIFrameElement = window.HTMLSpanElement;


How are you doing? The above may be a bit too specifically written for the issues in the demos I tried to test..

Announcement: repos for tests/utils

hallvord
Some things Mike Day should consider native support for :)

Announcement: repos for tests/utils