Linux – Convert OXPS to PDF or Image

conversionlinuxpdfxps

I've been trying to solve the problem of converting an .oxps file to .pdf or other file format. Any solutions for Linux out there?

I've been searching around and cannot come up with much thus far.

Maybe even something to convert to xps first and then pdf?


I've tried ImageMagick's convert and ghostscript, but no luck. Maybe I'm doing something wrong?

Note: I'm using Gentoo and/or Ubuntu.


EDIT

The solution is covered in the answer from @ThatGuy. However, for some reason, mudraw was not pulled in with mupdf-tools on ubuntu (I am running a headless 12.04.5 LTS ubuntu).

However, the source is available from MuPDF's website. I built the source and was able to solve the problem.

Best Answer

Method #1 (recommended)

Software requirements: Ghostscript/GhostXPS (version 9.19 or later).

To convert OXPS to PDF, simply execute the following command:

gxps -sDEVICE=pdfwrite -sOutputFile=/path/to/output.pdf -dNOPAUSE /path/to/input.oxps

This method preserves text layers.


Method #2 (deprecated)

(This works on Windows, Mac, and Linux, but converts text layers to images)

Use mudraw (included with MuPDF; mupdf-tools on Debian-based distributions) to convert the .oxps file to a series of .png files (converting directly to PDF doesn't work properly; fonts get messed up) with a resolution of 300 dpi:

mudraw -o mudraw_output_page_number_%d.png -r 300 input.oxps

Convert the .png files to a multipage PDF using ImageMagick's convert utility:

convert mudraw_output_page_number_*.png final.pdf

Note: If convert messes up the page order you can specify each individual .png file as the input (i.e., without using wildcards):

convert 1.png 2.png 3.png final.pdf

This should work on all platforms where MuPDF and ImageMagick are available (so on Windows, too).

Related Question