![]() So the answer is Yes, you can take an Existing WPF (XAML) Control, databind it and turn it into an XPS document - and its not all that difficult. Click Options and choose the publish option best for online or print viewing of your publication: Minimum Size Use this option for online viewing as a single page. Select Microsoft Print to PDF in the dialog box. For Save as type, select either PDF or X PS Document. In the XPS view application, click File and select Print from the dropdown menu. For File name, type a name for the publication. xw = XpsDocument.CreateXpsDocumentWriter(xpsd) Click File > Export > Create PDF/XPS Document > Create PDF/XPS. XpsDocument xpsd = new XpsDocument(filename, FileAccess.ReadWrite) dlg = new () ĭlg.FileName = "MyReport" // Default file nameĭlg.DefaultExt = ".xps" // Default file extensionĭlg.Filter = "XPS Documents (.xps)|*.xps" // Filter files by extensionįixedDocument doc = (FixedDocument)documentViewer1.Document Save Functionality is relatively simple (and is also from Eric Sinks article) public void SaveCurrentDocument() ![]() Microsoft XPS Document Writer appears as an available printer when you. Nor does it contain any save functionality as MS seem to have forgotten to include a Save button with the Document Viewer. The Windows operating system includes the Microsoft XPS Document Writer print driver. My sample is fairly simplistic, it doesn't include Page Sizing and Orientation which contains a whole different set of issues that don't work as you would expect. PageContent pageContent = new PageContent() ![]() The simplified code is a mere 10 lines long public void CreateMyWPFControlReport(MyWPFControlDataSource usefulData)įixedDocument fixedDoc = new FixedDocument() Actually after messing around with heaps of different samples, all of which are incredibly convoluted and require the use of Document Writers, Containers, Print Queues and Print Tickets, I found Eric Sinks article about Printing in WPF By design, you need to enter the file name when you are trying to print it. ![]()
0 Comments
Leave a Reply. |