printed to PDF printers, page background is not transparent.
Categories
(Core :: Printing: Output, defect, P3)
Tracking
()
People
(Reporter: v+mozbug, Unassigned)
Details
Attachments
(11 files)
|
501 bytes,
text/html
|
Details | |
|
502 bytes,
text/html
|
Details | |
|
7.95 KB,
application/pdf
|
Details | |
|
7.79 KB,
application/pdf
|
Details | |
|
14.09 KB,
application/pdf
|
Details | |
|
14.08 KB,
application/pdf
|
Details | |
|
12.43 KB,
application/pdf
|
Details | |
|
25.00 KB,
application/pdf
|
Details | |
|
58.84 KB,
application/pdf
|
Details | |
|
58.86 KB,
application/pdf
|
Details | |
|
117.50 KB,
application/pdf
|
Details |
| Reporter | ||
Comment 2•8 years ago
|
||
| Reporter | ||
Comment 3•8 years ago
|
||
| Reporter | ||
Comment 4•7 years ago
|
||
Thinking about this more, as it gets closer to the time when I either have to fix this bug (with help, I don't have the background to do it alone in a reasonable time frame), or to write a PDF post-processor for the output files, I decided to check the standards again.
The earliest of CSS specs declares that the initial value for background-color should be transparent: https://www.w3.org/TR/CSS1/#background-color And so does the latest I can find: https://www.w3.org/TR/css-backgrounds-3/#backgrounds
It is reasonable, in this day of windowed GUI interfaces, that a user agent would want to have a (by default) white background to separate the content of its display from the background noise of the desktop and windows it overlaps. I can also think of useful reasons that a user may wish to configure that differently in certain circumstances, even making that transparent, and letting the other windows or the desktop be the background for the HTML presentation. But in any case, the window background should not be considered part of the HTML presentation, nor should it be included (by default) when printing.
Comment 5•7 years ago
|
||
Hi Glenn, sorry for the delay in following up from your comments on the Hacks blog.
If I'm understanding your use case correctly, you're trying to generate a watermark PDF from an HTML document by printing it in Firefox to a virtual printer.
This works correctly in Edge, but fails in Firefox as the resulting PDF includes an opaque white box behind the page content.
-
Is that correct?
-
Are you able to test the same using other platforms? (For example, macOS has native print-to-PDF functionality.)
-
Could you please upload a examples for me to mess around with? Especially: Two identical watermark PDFs from the same virtual printer, but one printed from Edge and one from Firefox, and a single base PDF to attempt to combine them onto. Instructions for using pdftk to accomplish the watermarking would also be helpful.
| Reporter | ||
Comment 6•7 years ago
|
||
| Reporter | ||
Comment 7•7 years ago
|
||
| Reporter | ||
Comment 8•7 years ago
|
||
| Reporter | ||
Comment 9•7 years ago
|
||
| Reporter | ||
Comment 10•7 years ago
|
||
| Reporter | ||
Comment 11•7 years ago
|
||
| Reporter | ||
Comment 12•7 years ago
|
||
| Reporter | ||
Comment 13•7 years ago
|
||
| Reporter | ||
Comment 14•7 years ago
|
||
So these are just test files, not the files of interest, which are far more complex. But they serve to demonstrate the issue.
fl.html and fr.html are the source files.... same file, one with the header floated left and the other with the header floated right.
fl.pdf and fr.pdf are the output of printing the source files from Firefox (release track, current version, done today, with the same results as a year ago). Output PDF print driver was from PDFill (but testing a year ago by a friend that had Adobe Distiller produced the same sort of results; 3 PDF print drivers produced the same results then, PDFill was one of them). So we concluded the issue was with Firefox, not the PDF print driver, especially when we got different results from Microsoft Edge, with all 3 print drivers.
fl-Microsoft Edge.pdf and fr-Microsoft Edge.pdf are the output of printing the source files from Microsoft Edge, through the PDFill PDF printer driver.
Then I used the pdftk Server command line program to add fr as a watermark to fl. Because fl doesn't have a transparent background, fr doesn't shine through.
Then I used the pdftk Server command line program to add fr-Microsoft Edge as a watermark to fl-Microsoft Edge. As demonstrated, both the left and right text shows up.
Using the files in various combinations, one can demonstrate that both files from Microsoft Edge have transparent backgrounds, but both files from Firefox have white backgrounds.
Earlier testing, IIRC, seemed to indicate that the white background does not cover the margin area, just the content box area.
Here is more info about pdftk. The PDFill program can also be used to do similar operations, with similar results, but this testing used pdftk to combine the files.
From the pdftk server manual https://www.pdflabs.com/docs/pdftk-man-page/
background < background PDF filename | - | PROMPT >
Applies a PDF watermark to the background of a single input PDF. Pass the background PDF’s filename after background like so:
pdftk in.pdf background back.pdf output out.pdf
Pdftk uses only the first page from the background PDF and applies it to every page of the input PDF. This page is scaled and rotated as needed to fit the input page. You can use - to pass a background PDF into pdftk via stdin.
If the input PDF does not have a transparent background (such as a PDF created from page scans) then the resulting background won’t be visible — use the stamp operation instead.
Here are the exact commands used today to combine the files for this demonstration. The pdftk installation was from a year or more ago, but I don't expect differences with today's version if there have been updates, because the problem is in the files generated by Firefox, from all indications.
"c:\program Files (x86)\PDFtk Server\bin\pdftk.exe" fl.pdf background fr.pdf output fl+fr.pdf
"c:\program Files (x86)\PDFtk Server\bin\pdftk.exe" "fl-Microsoft Edge.pdf" background "fr-Microsoft Edge.pdf" output "fl-Microsoft Edge+fr-Microsoft Edge.pdf"
| Reporter | ||
Comment 15•7 years ago
|
||
Oh, the margins and maybe the layout defaults between Firefox and Edge are apparently different, the text doesn't appear in exactly the same places in the PDF outputs from the two browsers. I'm not concerned about that, I didn't attempt to make them identical in that way.
Any other questions, I'm happy to try to answer.
| Reporter | ||
Comment 16•7 years ago
|
||
Forgot to answer your questions specifically. All the above was in response to question 3.
The others are easy to answer, but not real helpful.
-
Yes
-
No
-
See comments 14 & 15.
Comment 17•7 years ago
|
||
Using the PDFs provided, I can confirm your experimental results: the Edge PDFs have a transparent background, the Firefox ones do not.
However, I'm not able to generate PDFs with transparent backgrounds in any of the browsers I tested.
I tested the following browsers, which all produced opaque PDFs:
- Firefox on Linux
- Firefox on macOS
- Chrome on Linux
- Chrome on macOS
- Safari on macOS
All with the system PDF printer.
That leads me to believe that the Edge's behavior might actually be aberrant, and I'd expect it to match Chrome's once Microsoft finished switching engines later this year. :-(
This creates a pretty high barrier to changing the existing behavior (if that's even under our control; these assumptions might be baked into the system PDF printers on other platforms), as we'd have to convince ourselves that the prevailing practice was clearly incorrect, and that there would be significant user benefit (and minimal user harm) by deviating from other browsers' behaviors.
Though that's only speculation on my part. I'd want to hear from a layout module peer for anything definitive.
| Reporter | ||
Comment 18•7 years ago
|
||
First, Dan, thanks for the extra testing, and response to this issue, which had languished for a year. I had actually determined that Chrome on Windows also produces a white background. I have no ability to test on other OS.
Regarding the results of your testing, it is no surprise that Firefox and Chrome have consistent behavior from one OS to the next. Windows doesn't have a "system PDF printer" as far as I'm aware, but I guess it is convenient that the others do. I don't think the issue is in the PDF printers, but in the broswers.
Obviously you couldn't test Edge or IE on the other OS. Yes, I fear that a Chromium-based Edge may lose its standard-corforming transparent background, I have a friend that uses the insider builds, and as soon as it is released to that channel, I hope to have him test it and report to me, and to M$, if the behavior has changed. While M$ hasn't historically been known for slavish adherence to standards, it seems in this case they did conform, whether by accident or design.
The only really new information your testing provides is that about Safari.
The specs are very clear that the default background is to be transparent, regardless of what any browsers actually do. Because many web pages are not printed, and because most people print on white paper, and because most PDF printer drivers would know that most printers don't even have white ink, and so don't instruct them to do white fills, this issue is easy to overlook, unless trying to overlay PDF files as I tried.
Regarding the barrier to changing existing behavior... few people have ever noticed the difference between Edge & IE (which correctly produce transparent backgrounds) and the other browsers (which incorrectly produce a non-standard-conforming white backgrounds). I strongly suspect that few people would ever notice the difference between the current erroneous behavior of Firefox producing an erroneous non-standard-corforming white background, with a changed behavior of Firefox producing a standard-conforming transparent background, if you were to fix this issue.
On the other hand, there is a middle ground: give the user control of the background color, both for printing and for display. There are already settings to choose a color, but not transparency. To avoid backwards incompatibility with the past and current erroneous non-standard conforming behavior, you could leave the default as opaque white, and simply document how to achieve a standard-conforming transparent background via browser settings (once it is made possible).
| Reporter | ||
Comment 19•7 years ago
|
||
Another point: which is more useful, a white background, or a transparent background?
- It takes work by browsers to generate a white background.
- It takes space in PDF files to describe the white background.
- White backgrounds prevent overlay of documents.
- It takes work by printer drivers to ignore white backgrounds.
Transparent backgrounds have none of these deficiencies.
Are there any benefits to white backgrounds?
| Reporter | ||
Comment 20•7 years ago
|
||
The "Correct answer" on this page: https://forums.adobe.com/thread/2190851 makes an interesting statement:
"PDF files do not have the concept of a “background color” for a page. Most applications simply layout the content of a page on a “blank” background, i.e. one that has no color at all, which is very different than an explicit white background. A white background would need to be defined as a rectangle filled with white covering the entire printed area and positioned behind any other content."
Sounds like the default background color for PDF files is transparent, similar to the HTML standard. So to achieve a white background, it is necessary to emit those big white rectangles, but it is not at all clear that a white background should be achieved, nor that the big white rectangles are appropriate, for either HTML or PDF.
The answer indicates that finding such a white background in a PDF file would be a surprise, thus making it hard to change the background color, as the second part of the question asks (although the first part of the question is asking something far more complicated).
| Reporter | ||
Comment 21•7 years ago
|
||
Continuing the thoughts in Comment 19:
- It is far easier to add a background to a transparent PDF than to subtract opaque white rectangles. The pdftk and PDFill tool sets (and others) both allow overlays of watermarks, which could be solid color, picture, watermark, or any other type of background, but doing so only works if the starting PDFs have no background, or a transparent background.
| Reporter | ||
Comment 22•7 years ago
|
||
As semi-expected, the early version of Edge-based-on-Chromium has a white background. Bug will be reported soon. I'll attach the files, but they aren't worth much.
| Reporter | ||
Comment 23•7 years ago
|
||
| Reporter | ||
Comment 24•7 years ago
|
||
| Reporter | ||
Comment 25•7 years ago
|
||
| Reporter | ||
Comment 26•7 years ago
|
||
The regression in Chromium Edge has been reported to M$ by my friend through the insider program.
I discovered that my ancient version of Adobe Photoshop honors the transparency (or not) of PDF files, and by using it confirmed that the PDFs produced by Firefox have transparent margins, but the ones produced by Chrome and Chromium Edge do not, and that the ones produced by released IE & Edge have fully transparent backgrounds.
So it seems that current Firefox behavior is different than current IE behavior, and different than Chrome behavior.
So compatibility with Chrome is not a reason not to make changes to Firefox in this regard, because it isn't.
Compatibility with a standard is a far superior position that compatibility with Chrome.
Comment 27•4 years ago
|
||
im sorry
hope it can help,
for printer drivers can be visited here: https://www.my-hpdrivers.com
thank you
Updated•3 years ago
|
Description
•