4

I am looking at SlimerJs (v0.9.6) as an option for rendering PDFs. I have marked up the HTML that the PDF should be rendered from and I run this command to render it out:

slimerjs renderPdf.js

In my renderPdf.js file I have defined:

var webpage = require('webpage').create();
webpage
  .open('page.html') // loads a page
  .then(function() {
    webpage.viewportSize = { width: 1240, height: 1754 };
    webpage.render('page.pdf', { 
                      format:'pdf',
                      onlyViewport:true 
                    });
    slimer.exit();
  });

I see a window open with the HTML page rendered exactly as expected but it doesn't render to the defined file, page.pdf. Is there something I am missing to get it to render out to a file? Or perhaps there's a known issue around this? Any help much appreciated :)

travega
  • 8,284
  • 16
  • 63
  • 91
  • 1
    Same here, it does render png files though. I'm using the phantom.js rasterize script for comparison. – three Aug 04 '15 at 19:55
  • use the slimer 0.10pre release. 0.9.6 doesn't have pdf rendering included yet. – three Aug 04 '15 at 21:36

2 Answers2

2

Please note in order to print the webpage to pdf slimer js requires cups pdf. Install the cups pdf with this command then it will render the page to a local file. And higher version than 0.9.6 is needed (0.10.*).

sudo apt-get install cups-pdf
Nirojan Selvanathan
  • 10,066
  • 5
  • 61
  • 82
0

As per @three's comment suggestion I used the 0.10pre release version and was able to get a PDF. Mind you at the time of posting this release is not super stable so might want to wait for the final release build.

Community
  • 1
  • 1
travega
  • 8,284
  • 16
  • 63
  • 91