Phantomjs: Add ability to render PDF without applying `@media print` styles

Created on 14 Sep 2015  路  8Comments  路  Source: ariya/phantomjs

I find that for any Wikipedia page, the header and left column are missing when i generate a PDF, however the entire screen shows up when I generate a PNG.

Test URL - https://en.wikipedia.org/wiki/Tree

PDF Version - The entire left column with the Wikipedia globe, Main Page, Contents, etc menu is missing from the PDF. The top header (with the grey gradient, Search Box, etc) is missing as well. Indeed, the PDF contains only the main article/content area. With the white background and the word Tree.

The only configuration I am using is -

page.viewportSize = { width: 1920, height: 1280 };

I'd love to use PDF instead of PNG if I could.

Need code stale

All 8 comments

Looking at Wikipedia's source (view page source) I can see that the main

shows up fine. But the
with the inner divs mw-head and mw-panel don't appear. Hmmm

PDF uses the css print if any is set, to see if there is a problem with phantomjs or if it is just comming from the print css, try to print the page in any browser and see if you get the header and left menu.

I can confirm that this is due to Wikipedia's style sheet suppressing the "chrome" in print mode.

So, let's call this a feature request: add a mode in which we render to PDF without applying @media print styles. That shouldn't be hard. However, we probably aren't going to get to it ourselves for _quite some time_ -- we are all tied up with harder and more urgent issues (like being way out of date on both Qt and Webkit, even in 2.0). A patch would be welcome.

+1

+1

+1

+1

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

Was this page helpful?
0 / 5 - 0 ratings