Forum How do I...?

Printing html that's rendered via angular

Julian
Hello!

I'm testing your product, prior to purchasing a commercial license. I've created a test website that is being rendered completely with AngularJS, and am running into issues trying to get Prince to correctly convert the webpage. I've tried on both Ubuntu 14.04 and on Windows 7 with no luck. When using Windows, I'm trying the following command in order to convert the website:

C:\Program Files (x86)\Prince\Engine\bin>prince --javascript "http://ip.address.here:8080/" -o prince
WindowsTest4.pdf


Upon running this command I am getting the following errors.

prince: http://ip.address.here:8080/assets/angular.min.js?compile=false
:140: error: TypeError: undefined value is not an object
prince: http://ip.address.here:8080/assets/angular-resource.min.js?comp
ile=false:6: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/docs.min.js?compile=false:12
: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/services.js?compile=false:2:
 error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/angular-tree-control.js?comp
ile=false:288: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/ui-bootstrap-tpls-0.12.1.min
.js?compile=false:8: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/json-formatter.min.js?compil
e=false:7: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/ngStorage.min.js?compile=fal
se:1: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/conduitApp.js?compile=false:
9: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/AccessToken.js?compile=false
:9: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/javaScript/jsEnv:1: error: TypeErro
r: value is not an object
prince:  http://ip.address.here:8080/assets/dashController.js?compile=fa
lse:4: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/nodeController.js?compile=fa
lse:3: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/javaScript/pageEnv?boxHeight=0.5in:
1: error: TypeError: value is not an object
prince:  http://ip.address.here:8080/assets/printController.js?compile=f
alse:3: error: TypeError: value is not an object


What am I doing wrong, or is Prince unable to handle webkit?
mikeday
It looks like AngularJS is using a DOM function Prince doesn't support yet. Is there a simple example page online that replicates the problem so we can try it ourselves?
Julian
Pretty much any website that dynamically renders javascript seems to give the same type of error. For example Angular's tutorial webpage uses AngularJS to dynamically render some aspects of the page:

http://campus.codeschool.com/courses/shaping-up-with-angular-js/intro

Whenever trying to run Prince on this webpage it also fails with the same TypeError.
mn4367
In this post I described a workaround for a similar problem, rendering math with MathJax, a JavaScript framework which isn't yet fully supported by Prince.

In my case I had to rearrange some SVG DOM elements with JavaScript to get it working, in your case it could even be simpler, all you have to do is to remove all JavaScript references from the rendered DOM after processing with PhantomJS (I think).

If JavaScript programming is not your cup of tea don't hesitate to ask, assembling a simple example shouldn't be too difficult.

Edited by mn4367