Apparently the screen resolution is not set to 72 dpi on every platform we support.
Comment #1
Posted on Jul 13, 2012 by Quick RabbitDiscussion: https://groups.google.com/forum/?fromgroups#!topic/phantomjs/YQIyxLWhmr0.
Comment #2
Posted on Jul 13, 2012 by Quick RabbitRelated pull request: https://github.com/ariya/phantomjs/pull/286.
Comment #3
Posted on Sep 19, 2012 by Quick RabbitRescheduled to 1.8.
Comment #4
Posted on Oct 15, 2012 by Happy HorseI agree that we should provide a consistent default value of 72 for resolution (DPI) fonts, PDFs, etc. across all supported platforms. However, I also think we should provide the user with a mechanism to set their own choice DPI, as mentioned by other users in comments on the Pull Request and in forum discussions, e.g. https://groups.google.com/forum/m/?fromgroups#!topic/phantomjs/V9EU0UdT1cg
Comment #5
Posted on Dec 23, 2012 by Quick RabbitRescheduled to 1.9.
Comment #6
Posted on Dec 23, 2012 by Quick RabbitI found that all we need is to implement physicalSize() for our minimalistic QPlatformScreen implementation. Because it was not implemented, the default 100 dpi was used and that causes the inconsistency.
Comment #7
Posted on Dec 23, 2012 by Quick RabbitIt's more complicated on Windows because Qt just uses the values from GetDeviceCaps and LOGPIXELSX/LOGPIXELSY. According to http://stackoverflow.com/questions/645352/is-the-number-of-pixels-per-inch-standard-on-all-windows-pc-displays-logpixels, the return values could be anything from 88, 96, 120, and maybe even more variations on the future Windows version.
I think nothing we can do about Windows for the near future. Hence, I plan to change the issue title to only cover OS X and Linux.
Comment #8
Posted on Dec 23, 2012 by Quick RabbitLinux: Ensure we use 72 dpi. https://github.com/ariya/phantomjs/commit/3f42fb230f
Comment #9
Posted on Dec 23, 2012 by Quick Rabbit(No comment was entered for this change.)
Comment #10
Posted on Dec 23, 2012 by Quick Rabbit(No comment was entered for this change.)
Comment #11
Posted on Dec 23, 2012 by Happy Horse(No comment was entered for this change.)
Comment #12
Posted on Dec 23, 2012 by Happy HorseFiled Issue #934 to pursue fixing this for Windows in the future.
Comment #13
Posted on Dec 23, 2012 by Happy WombatStill not fixed for me :( For some reason I still have different pdf outputs from mac os x version and from linux version
Comment #14
Posted on Dec 23, 2012 by Quick RabbitWhat about PNG output? The PDF output relies on the print engine which may have some slight differences.
Comment #15
Posted on Dec 23, 2012 by Quick RabbitWith the 72 dpi change I have committed, QWebFrame::print gives zoomFactorX and zoomFactorY both to 1.
Comment #16
Posted on Dec 24, 2012 by Quick RabbitHere is a test script I used:;
var page = require('webpage').create(); page.content = '
Hello
'; page.render('dpi.pdf'); phantom.exit();The PDF results can be seen in the attachment, as well as the comparison screenshot.
- dpi-100.pdf 3.33KB
- dpi-72.pdf 3.31KB
- dpi-comparison.png 36.44KB
Comment #17
Posted on Dec 24, 2012 by Happy Wombattry this:
var page = require('webpage').create();
page.paperSize = { format: 'A4', margin: "1cm", };
page.content = "Test"; page.render("out.pdf"); phantom.exit();
out.1.6-linux-mypatch obtained with the force dpi=72 patch added to phantomjs 1.6 (https://github.com/ariya/phantomjs/pull/286)
- out-1.6-linux-mypatch.pdf 6.56KB
- out-1.8-linux.pdf 6.57KB
- out-1.8-macosx.pdf 3.56KB
- screen-shot.png 136.83KB
Comment #18
Posted on Dec 24, 2012 by Quick RabbitDid you try with version 1.8? Unfortunately, this one did not make it to 1.8. It will be part of 1.9, meanwhile you need to build it yourself.
- dpi-comparison.png 63.44KB
Comment #19
Posted on Jan 5, 2013 by Quick RabbitIssue 750 has been merged into this issue.
Comment #20
Posted on Mar 16, 2013 by Happy HorseThis issue has been moved to GitHub: https://github.com/ariya/phantomjs/issues/10659
Status: Fixed
Labels:
Type-Defect
Priority-Medium
Milestone-Release1.9
Component-Logic
Module-WebPage
Domain-Qt