开发者

PDF to XPS Converting via Microsoft XPS Document Writer

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜