tags:

views:

1045

answers:

2

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?

A: 

DOCINFO struct manages file names in print spooler but not linked with xps driver save dialog realization. But you may find Save dialog window, enter file name and close it programmatically. Read this article for example.

necrostaz
A: 

You will not get very good results with MSDW (bloated files, missing graphics and metada etc). It is better to use a direct PDF to XPS conversion such as PDFTron PDF2XPS (http://www.pdftron.com/pdf2xps/index.html).

Robert Duga