Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Chrome: Unexpected black fill in PDFs generated by Prince XML #2351

jwal opened this Issue Nov 8, 2012 · 13 comments


None yet
4 participants

jwal commented Nov 8, 2012

I'll let the attachments speak for themselves...


  • pdf.js 4dd0e02
  • Mozilla Firefox 16.0.2 (Ubuntu 12.10)
  • Google Chrome 22.0.1229.94 (Ubuntu 12.10)
  • Prince XML 8.1 rev 3

yurydelendik commented Nov 8, 2012

Looks like it's an absence of the fillRule for the canvas. Long story short: Firefox has mozFillRule, other browsers are still thinking. Read more at:

An implementation/support without this attribute will not look pretty or fast.


yurydelendik commented Nov 8, 2012

Small code to replicate the issue ( http://jsbin.com/ayoyej/1/edit ):

    ctx.rect(10, 10, 100, 40);
    ctx.rect(15, 15, 90, 30);
    ctx.mozFillRule = 'evenodd';

jwal commented Nov 9, 2012

Thanks for getting to the bottom of this so quickly. Out of interest, I had a go at working around this problem by generating slightly different PDFs. I have an example html file showing that something might be possible using Prince XML's --javascript option.

jwal commented Nov 20, 2012

I have a build of Chromium based on a modified WebKit that implements this feature. As stated, the operation was already available but just not exposed through the canvas.


That changeset exposes it. Note, for compatibility with pdf.js I named the attribute mozFillRule instead of the more conventional webkitFillRule!

After I have finished all testing, I will rework the patch and try to get it submitted to WebKit.

jwal commented Dec 19, 2012

I have now renamed the new property on the canvas in Chromuim to webkitFillRule (from mozFillRule). Here are some new links:

  • A patch to WebKit that adds the new property (see also WebKit bug 105508)
  • A patch to pdf.js that allows use of the webkitFillRule property
  • The example.pdf rendered using pdf.js with the above modification
  • A zero-installation zip release of Chromium that was linked against the modified WebKit
  • A screenshot of the example PDF rendering properly using the modified pdf.js the modified Chromium

I guess my next task is to get these patches accepted, with any suggested improvements applied.

@jwal jwal added a commit to jwal/pdf.js that referenced this issue Dec 20, 2012

@jwal jwal Added example PDF for Issue #2351 709b7e9

jwal commented Jan 9, 2013

My WebKit patch seems to have triggered a discussion on the webkit-dev mailing list with an update to the HTML5 specification.


yurydelendik commented Jan 9, 2013

@jwal, thank you for doing that. We have similar discussion here at #2534. However I can accept #2487 first (when the last comment is addressed) -- the specification defines fillRule now. We can always change the code to make it work with eoFill later.

jwal commented Apr 16, 2013

Well, the browser has been updated. Thanks to Rik. He has also provided a patched viewer that uses the new browser feature:

See it working here: http://jwal.github.io/pdf.js/pdf.js-cabanier/web/viewer.html?file=../../example.pdf

gus2986 commented May 3, 2013

Please help with more info about it, I am trying to install the patched pdf.js without results, could you please explain more how to use this patch? something like step by step for beginners. Thanks

gus2986 commented May 6, 2013

Well, I did the changes according Pull Request #3201: Adds fill('evenodd') as alternative for mozFillRule,,, question do I have to have webkit full pack at the server running PDF.js? any config necessary at webkit side? Thanks for the help.
If I cant solve this issue, I will pay support for a hand here, if somebody is able to help me for fix the PDF.js package at my server.

gus2986 commented May 6, 2013

Got it, I was complicating the solution, thanks for the help.


brendandahl commented May 8, 2013

Fixed by above PR.

@brendandahl brendandahl closed this May 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment