deanmao / node-chimera

A new kind of headless webkit integration for nodejs; a great alternative to phantomjs.
http://www.deanmao.com/2012/08/13/enter-chimera/
MIT License
847 stars 45 forks source link

PDF rendering #20

Open underbyte opened 11 years ago

underbyte commented 11 years ago

The capture function does a nice job of rendering a pdf but is their a way to set the viewport, orientation, and margin? If not would this be possible with Chimera?

deanmao commented 11 years ago

I could add some stuff to alter the viewport, but I'm not sure if I could control the pdf viewer. It's probably using whatever pdf plugin your browser would be using, which probably has it's own set of controls. Are you doing this on linux or mac?

underbyte commented 11 years ago

I'm doing this on linux. I was just wondering cause phantomjs is about to set those parameters, so I was hoping chimera could do the same.

deanmao commented 11 years ago

On phantom you can set the viewport, but I don't think you could rotate or zoom the pdf. Those sound like pdf controls.

underbyte commented 11 years ago

In phantomjs setting the paperSize and viewportSize objects controls how the pdf will look once rendered. It doesn't give you free control of rotation, just landscape or portrait. https://github.com/ariya/phantomjs/wiki/API-Reference

No idea how phantomjs is doing through Qt but some of the code is in webpage.cpp. https://github.com/ariya/phantomjs/blob/master/src/webpage.cpp

deanmao commented 11 years ago

Yeah, it's just setting the viewport in the code, it's not doing anything special like pdf controls. The paper size thing is just a fancy viewport control where you specify the paper type and it converts that into a pixel dimension, but you could just specify the pixel dimension directly too. At the moment chimera is just hardcoded to a 1024x768 viewport.

kristjanjansen commented 11 years ago

+1 on allowing setting custom viewport size, please.

xMythicx commented 11 years ago

+1

pdelanauze commented 11 years ago

+1

cjpartridgeb commented 11 years ago

@guber @kristjanjansen @xMythicx @pdelanauze Changing the viewport when printing for PDF will not affect the PDF output as I've found out recently. However you can adjust the QPrinter configuration like the renderPdf method in https://github.com/ariya/phantomjs/blob/master/src/webpage.cpp#L1065