Printing pdf document with 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 Save Dialog, which requests file name (*.xps) where to save result. Everbody advices DOCINFO to solve this problem, but I didn't find any example of using. I need programatically print PDF File via Microsoft XPS Document Writer with default output file name. How should I use DOCINFO in this situation?
Can you help me?
Summary: 1. Adobe PDF represents a two dimensional document in a way that allows it to be changed independent of its software, hardware, or operating system; XPS is a document management software that allows the user to view, annotate, convert, sign, and print XPS documents.
The Microsoft XPS Document Writer (MXDW) is a print-to-file driver that enables a Windows application to create XML Paper Specification (XPS) document files on versions of Windows starting with Windows XP with Service Pack 2 (SP2).
In the Save as type list, select PDF Files (*. pdf) or XPS Files (*. xps) , and then choose Save . In the Document Export Options dialog box, select a Publish Range , whether to Include Non-printing Information , and ISO 19500-1 compliance (PDF only).
You can't reliably print by spawning Acrobat Reader unless you give it a desktop session and there will be a user there, because it sometimes pops up dialogs that need user attention.
Also it violates Adobe's licence if used unattended.
You can, however print using Ghostscript.
There is a C# interface to Ghostscript called Ghostscript.Net that I've used successfully on some very large projects. Both Ghostscript and Ghostcript.Net are free & open source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With