Tuesday, May 1, 2012

Fixing PDF printing problems on Ubuntu 12.04

Between Ubuntu 11.10 and 12.04, a number of backend changes were made to better support the PDF workflow that the Linux and Mac communities are adopting of late. CUPS was updated from 1.5.0 to 1.5.2. Poppler is used as a PDF toolset; it was updated from 0.16.x to 0.18.x. Ghostscript is still around, but 9.05 changed some font detection behavior.

At work, we use a web vendor that provides us output from a QuarkXpress PDF software on their web server. The PDFs we get from them will not print in Google Chrome on Ubuntu 12.04 (I have bastardized CUPS 1.5.0 parts into some 11.04 installs I maintain: that seems to work). We currently use Brother and Samsung printers: the vendor uses HP, and they said that works. If their PDF is saved as a new PDF (via "print as PDF" or most conversion tools), it will print fine; otherwise, its PCL XL errors and/or 95% of the page missing.

Multiple websites and bug reports online, point towards changing the MIME types in CUPS as a solution. For me, its a half solution: disabling some conversions can yield some output; but its still only 90% complete. However, the tool to fix the output, came with 12.04: pdftocairo. Using assorted online references + hints from the weird scripts Brother uses for its own drivers (which I don't really use), I was able to make my own print filter to "wash" PDF output. You're also supposed to be able to define your own MIME type rules: I ended up patching the default set instead.

I've tested this modification on an HL-4040 (default driver), an HL-2140 (default driver), and a MFC-8480 (Postscript driver worked; BRScript default driver is a maybe). It is my humble suggestion that someone endeavour to make a version of pdftocairo, that can be called directly to handle print job conversions.

Update 5-29-2012: changed the script significantly to support multi-copy printing. pdfunite comes with pdftocairo.

Update 6-1-2012: someone caught a typo in one of my paths.


1. In a terminal, sudo bash or login as root.
2. Make the /usr/lib/cups/filter/pdfwash file with your favorite text editor (nano or leafpad works).
3. Using the text editor, change the lines in the /usr/share/cups/mime/cupsfilters.convs file to look like what I posted.
4. chmod a+x /usr/lib/cups/filter/pdfwash
5. /etc/init.d/cups/restart
6. Exit the terminal.



# CUPS filter to wash PDF output for printing
# Version 1.1, 5-29-2012, Michael Adams, unquietwiki.com


# Make original copy of washed PDF
mkdir /tmp/pdfwash
temp_pdf=`mktemp /tmp/XXXXXX.pdf`
pdftocairo -q -pdf -origpagesizes $6 /tmp/pdfwash/0

# Attempt to make copies of PDF
for ((i=0;i<$4;i++)) do
   cp /tmp/pdfwash/0 /tmp/pdfwash/$i

# Combine and display multi-copy, else the original single copy
if [ -e "/tmp/pdfwash/1" ]
   pdfunite /tmp/pdfwash/* $temp_pdf
   cat $temp_pdf
   cat /tmp/pdfwash/0

# Remove temp files
rm $temp_pdf
rm /tmp/pdfwash/*

exit 0


application/postscript        application/pdf            0    pstopdf
application/vnd.adobe-reader-postscript    application/vnd.cups-postscript    0    pstops
application/pdf        application/vnd.cups-pdf        0    pdfwash
application/vnd.cups-pdf-banner    application/vnd.cups-pdf    33    bannertopdf
#application/pdf        application/vnd.cups-postscript    0    pdftops
#application/vnd.cups-pdf    application/vnd.cups-postscript    0    pdftops
application/postscript        application/vnd.cups-postscript    66    pstops

Related online tickets

* Google Chrome / Brother bug
* Poppler PDF bug
* Ubuntu Brother printing bug
* Debian Brother printing bug
* Another Debian print bug


  1. I have PDF printing problems on 11.10 but the above fix is not usable there; the file /usr/share/cups/mime/cupsfilters.convs does not exist.

  2. In my case, simply printing a page as a PDF file, either from my browser or evince (the document viewer, fails most of the time but not always. I can successfully print web pages as postscript documents but the then evince claims that printing a postscript file as a pdf file is not supported! I have not tried printing documents to my physical printers.

    I am losing confidence in Ubuntu.

  3. This comment has been removed by a blog administrator.

  4. This comment has been removed by a blog administrator.

  5. On Ubuntu 12.04 (converted from 10.04 LTS), the path to the filters is:


    "filter" not "filters". Also, I modified the script to use mkdir -p /tmp/pdfwash because the script does not appear to delete the directory later. Unfortunately, the machines this is on are remote and I need to wait for the users to try it in the morning before I know if it worked.

  6. Unfortunately, this did not work for me. Something is going to the printer (a Toshiba eStudio 165), but after a while the light on the printer stops blinking and nothing comes out. Rats :-(

  7. BTW, that anon above was me, but Blogger seems to have decided that I did not really have a name. Odd.

    1. No worries. Thanks again for catching the typo!

  8. Thanks Michael,

    Your fix seems to have cleared one of my printing issues with 12.04. Previously, I could only print once after resetting the printer. The second print job would only print blank pages. I have tested the system after making the changes that you put at comment 70 for bug 950713 at https://bugs.launchpad.net/ubuntu/+source/cups-filters/+bug/950713/comments/70 and seems to work just fine.

    I am very grateful to you for the trouble you took to post the fix - it has really been very useful! Keep up the good work.

    1. Thank you. You reminded me that I need to update my forum posts sometime with the newer solution.

  9. There was a new version of cups-filters pushed to production release for 12.04 a few days ago and that seems to have helped. I backed out the above changes and things are still fairly stable. This was on a Toshiba e-Studio 165 via network.

  10. This comment has been removed by the author.

  11. In that case make use of next software to come back .pdf files

    repair pdf application must assist you

  12. Hey,

    Really wonderful blog and unique content.i like it.. thanks for share....keep it up..

    Visit my link Brother Printer Technical support

  13. I'm having the same issue in Ubuntu 12.10 and this fix doesn't seem to help. Once I made all the changes PDFs stopped printing completely.

  14. Is /etc/init.d/cups restart, not /etc/init.d/cups/restart

    1. Or service cups restart ? Thanks for the catch: haven't looked at this in a few months.

  15. After changes even no empty PDF file is created. In cups error log shows this error:
    Returning IPP client-error-document-format-not-supported for Print-Job (ipp://localhost:631/printers/PDF) from localhost

  16. I forgot to create a back up from original settings (cry).. i was hoping u (or anyone) has the original settings for /usr/share/cups/mime/cupsfilters.convs


  17. hi Team

    how to possible

    print send to ubuntu from server 2008

    printer connected to ubuntu
    and print send from server 2008
    server ip is
    ubuntu ip is
    i am try but problem is still..

  18. This online pdf merger or pdf combiner or pdf joiner will easily merge pdf files together with use of any software or any registration. pdf merge