How do I print to PDF from wine?
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:
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.
Solution 3:
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.