Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF to XPS Converting via Microsoft XPS Document Writer

Tags:

c#

xps

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?

like image 594
Mykhail Galushko Avatar asked Feb 18 '10 08:02

Mykhail Galushko


People also ask

What is difference between XPS document and PDF?

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.

What is Microsoft XPS document Writer PDF?

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).

Can we convert your document in XPS by using export?

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).


1 Answers

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.

like image 110
Terry Carmen Avatar answered Oct 25 '22 00:10

Terry Carmen