Convert PDF to XPS and XPS to PDF in Java

Spire.PDF for Java has a powerful conversion feature. This article, we will demonstrate how to use Spire.PDF for Java to convert PDF to XPS and XPS to PDF in high quality.

PDF to XPS

import com.spire.pdf.*;

public class PDFtoXPS {
    public static void main(String[] args) {
        //Load the PDF file
        PdfDocument pdf = new PdfDocument();
        pdf.loadFromFile("Sample.pdf");
        
       //Save to XPS 
        pdf.saveToFile("ToXPS.xps", FileFormat.XPS);
    }
}

Effective screenshot after converting PDF to XPS:

Convert PDF to XPS and XPS to PDF in Java

XPS to PDF

import com.spire.pdf.*;

public class PDFtoXPS {
    public static void main(String[] args) {
        //Load XPS 
        PdfDocument pdf = new PdfDocument();
        pdf.loadFromXPS("ToXPS.xps");

        //Save to PDF
        pdf.saveToFile("toPDF.pdf", FileFormat.PDF);
    }
}

Effective screenshot after converting XPS to PDF:

Convert PDF to XPS and XPS to PDF in Java