node-chimera
node-chimera copied to clipboard
PDF rendering
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?
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?
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.
On phantom you can set the viewport, but I don't think you could rotate or zoom the pdf. Those sound like pdf controls.
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
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.
+1 on allowing setting custom viewport size, please.
+1
+1
@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