How do I print to PDF from wine?

27,238

Solution 1

The answer is cups-pdf

sudo apt-get install cups-pdf

or from Ubuntu 16.04 on

sudo apt-get install printer-driver-cups-pdf

If there's no such folder, create PDF at your home:

mkdir ~/PDF

Now you're set to go. From MS Word, do Print -> Select PDF as printer -> wait for the printing to complete (it takes some time).

Solution 2

I support runeks' answer.

However, I kept having problems installing the SaveAsPDF.exe extension - it never showed up as being installed.

I finally realized that I had used PlayOnLinux to install Office rather than pure Wine, and this meant using the PoL Wine prefix.

This thread (in Italian!) helped me solve it:

http://forum.ubuntu-it.org/viewtopic.php?t=447961&p=3510913

Basically had to look in my /home/name/.PlayOnLinux/wineprefix folder to discover the correct WINEPREFIX path, then used that to run the .exe file.

Solution 3

cups-pdf didn't work properly for me, here's what I did:

Download the official extension from Microsoft's website. It didn't work for me eihter initially, but this is because I have Microsoft Office installed in a separate Wine prefix.

To find out if you have Word installed in a separate prefix, look at the file ~/.local/share/applications/wine/Programs/Microsoft Office/Microsoft Office Word 2007.desktop. Locate the line that starts with "Exec". On my system it looks like this:

Exec=env WINEPREFIX="/home/rune/.wine_office2007" wine C:\\\\windows\\\\command\\\\start.exe /Unix /home/rune/.wine_office2007/dosdevices/c:/users/rune/Start\\ Menu/Programs/Microsoft\\ Office/Microsoft\\ Office\\ Word\\ 2007.lnk

From this I can see that Office is installed in the prefix /home/rune/.wine_office2007.

Now go to the folder where you downloaded the official PDF add-on. And run the .exe file using the following command, replacing <prefix> with the prefix in the "Exec" line of your Word .desktop file.:

WINEPREFIX="<prefix>" wine SaveAsPDFandXPS.exe

In my case the prefix is /home/rune/.wine_office2007, so the command to install the add-on becomes:

WINEPREFIX="/home/rune/.wine_office2007" wine SaveAsPDFandXPS.exe

After doing this, restart Word, and you should see the option to save as a PDF in the Save As file menu.

Share:
27,238

Related videos on Youtube

mreq
Author by

mreq

Updated on September 18, 2022

Comments

  • mreq
    mreq over 1 year

    I am running MS Office under wine and would like to print PDF documents.

    Installing the official extension via wine does nothing.

  • Chriki
    Chriki over 10 years
    +1, just a note: I didn’t have to manually create the ~/PDF folder; this was done automatically for me (CUPS-PDF version 2.6.1-6, Ubuntu 12.04).
  • logion
    logion almost 10 years
    Make sure that you create the PDF folder in your home directory. Also shut down all programs that use wine and manually kill any wine processes still running (check with ps ax | grep wine): killall wineserver && killall winedevice.exe This should force the list of available printers in Wine (and Word) to be reset. Alternatively you could prefer to reboot.
  • Admin
    Admin over 9 years
    Once cups-pdf installed, you need to create a new PDF printer from the control panel in Ubuntu. This "printer" will be available for the whole system (including wine).
  • Francisco Luz
    Francisco Luz over 7 years
    Just installing cups-pdf didn't work for either but after rebooting the computer it worked just fine.
  • Francisco Luz
    Francisco Luz over 7 years
    My worked only after rebooting the computer.
  • Marius
    Marius almost 7 years
    And the printing does not appear to be well-translated. I have two-color tables, equations, and transparent boxes, and, when printing using cups-pdf, all three come out somewhat strange. The transparent box is pixelated and somewhat visible, some variables are misplaced in the equations, and the second color of the tables is blurred into the first color. Any ideas?
  • opinion_no9
    opinion_no9 over 5 years
    in U 18.04+ it does not work any more, the CUPS-PDF printer disappears from the GUI menue. Any idea how to fix that?
  • yelly
    yelly about 4 years
    Thanks! But printing is very slow and the PDF file is not good. You can not select and copy text normally from it.
  • Michaël
    Michaël almost 4 years
    Link rot: the extension is no longer there.