Convert PDF to XPS with Microsoft XPS Document Writer

Printing a PDF using Microsoft XPS Document Writer:

string filename = "C:\\1.pdf"; Process process = new Process(); process.StartInfo.Verb = "PrintTo"; process.StartInfo.FileName = @"C:\Program Files\Adobe\Reader 9.0\Reader\acrord32.exe"; process.StartInfo.Arguments = "/t \"C:\\1.pdf\" \"Microsoft XPS Document Writer\" \"xps\" XPSPort:"; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.Start(); process.StandardOutput.ReadToEnd(); process.WaitForExit(); 

The only problem is the "Save dialog", which asks for the file name (*. Xps), where the result should be saved. Everbody advises DOCINFO to solve this problem, but I have not found any usage example. I need to programmatically print a PDF file using Microsoft XPS Document Writer with the default output file name. How to use DOCINFO in this situation?

Can you help me?

+7
c # xps
source share
2 answers

You will not be able to print reliably, spawning Acrobat Reader, if you do not have a session on the desktop, and the user will be there, because sometimes dialog boxes pop up that require the user's attention.

It also violates the Adobe license if used unattended.

However, you can print using Ghostscript.

There is a C # interface for Ghostscript called Ghostscript.Net, which I have successfully used in some very large projects. Both Ghostscript and Ghostcript.Net are free and open source.

0
source share

The DOCINFO structure manages the file names in the print spooler, but is not related to the implementation of the xps driver save dialog. But you can find the "Save" dialog box, enter the file name and close it programmatically. Read an article , for example.

-one
source share

All Articles