C# – How to convert from PDF to XPS

acrobatcnetpdfxps

I use the following method to print a XPS file with adobe acrobat:

private void GenerateXPS(String filename)
        {
            Process proc = new Process();
            proc.StartInfo.FileName = "AcroRd32.exe";
            proc.StartInfo.Arguments = "/t " + filename + ".pdf" + " " + "\"Microsoft XPS Document Writer\"";
            proc.Start();
        }

But the problem is, the Microsoft XPS Document writer needs a filename where to store the document. Now I'm asked to enter this filename by Adobe Acrobat, but I want to pass this filename as well in the arguments. Or if this is not possible just use the same filename. Is this possible?

Best Answer

If it isn't mandatory that you use acrobat, you might try printing the file directly to the Microsoft XPS Document writer. You can do this without the UI popping up. (see Feng Yuan's blog post for more details)