6

I create a PDF (using php library mPDF) with a full size background image on the body tag:

body {
    background: url("..path/to/bg.jpg") center no-repeat;
    background-size: cover;
    background-image-resize: 6;
    background-image-resolution: 300dpi;
}

It looks just fine in Chrome's, IE's and Acrobat's PDF viewers, but horrible in FF: enter image description here

Any idea how I can handle this for Firefox? I played with the CSS, using width and height, different resolutions, embedding as .svg, but to no success.

That Brazilian Guy
  • 3,328
  • 5
  • 31
  • 49
xsonic
  • 195
  • 4
  • 11
  • Same problem here. Full page background is blurry and there is also a scale problem : width & height are only 25% of the page. I think that there is no solution today, it looks like a pdf.js bug and we must wait for an update... (At least you should have a message : this pdf is not displayed properly, or something...) – FLX Mar 28 '14 at 10:37
  • I looked in firefox nightly, the scale bug on printed pdf is fixed, bug the blurred background is still here. It's just a matter of time. – FLX Mar 28 '14 at 10:49
  • Scaling works fine for me. For now, I have created an absolute positioned image, set in the background via z-index. Working fine. – xsonic Mar 29 '14 at 11:42
  • you didnt have a problem with the auto page break being triggered when using an image? i sure did, i couldnt make a full page background image & of course pdfjs was blurry... but eventually i saw the [size constraint](http://mpdf1.com/manual/index.php?tid=245) section in the manual which seems to finally work (full page size image without bugs) – kn00tcn Oct 23 '14 at 23:40
  • 2
    The blurry is caused by the repeat property. –  Aug 13 '15 at 12:15
  • It is now 2018 - exactly 4 years later - and this still happens... – Stefan Mar 12 '18 at 08:28

2 Answers2

12

It's caused by a bug in Firefox's pdf.js that manifests when PDF files were generated from mpdf with background: no-repeat on its HTML source.

As a work-around, removing the no-repeat property avoids the bug.

That Brazilian Guy
  • 3,328
  • 5
  • 31
  • 49
0

locate the file mpdf.php

change $this->_out(sprintf('/YStep %d',99999));

to $this->_out(sprintf('/YStep %d', 1024));

and $this->_out(sprintf('/XStep %d',99999));

to $this->_out(sprintf('/XStep %d', 1024));

These changes did work with me

Montaser El-sawy
  • 800
  • 1
  • 8
  • 14