XPS file format

The XPS format is getting more and more popular as a PDF replacement or to render a FixedDocument in WPF applications.

Since Windows Vista, the Microsoft XPS Document Writer is available on any machine and can be used to create XPS documents. Generally, it can be used to print into this specific printer driver. But using TX Text Control, you can print into an XPS file without showing the printer or print status dialog. The following C# code for TX Text Control .NET for Windows Forms exports the current document as an XPS:

if (Environment.OSVersion.Version.Major < 6)
    return;

PrintDocument pd = new PrintDocument();
PrintController printCtl = new StandardPrintController();
pd.PrintController = printCtl;

pd.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = "c:\\test.xps";

textControl1.Print(pd);