Search Results

Search found 3 results on 1 pages for 'xpsdocumentwriter'.

Page 1/1 | 1 

  • Creating WPF components in background thread

    - by mizipzor
    Im working on a reporting system, a series of DocumentPage are to be created through a DocumentPaginator. These documents include a number of WPF components that are to be instantiated so the paginator includes the correct things when later sent to the XpsDocumentWriter (which in turn is sent to the actual printer). My problem now is that the DocumentPage instances take quite a while to create (enough for Windows to mark the application as frozen) so I tried to create them in a background thread, which is problematic since WPF expects the attributes on them to be set from the GUI thread. I would also like to have a progress bar showing up, indicating how many pages have been created so far. Thus, it looks like Im trying to get two things to happen in parallell on the GUI. The problem is hard to explain and Im really not sure how to tackle it. In short: Create a series of DocumentPage's. These include WPF components These are to be created on a background thread, or use some other trick so the application isnt frozen. After each page is created, a WPF ProgressBar should be updated. If there is no decent way to do this, alternate solutions and approaches are more than welcome.

    Read the article

  • WPF to XPS in landscape orientation

    - by Felix
    Hello, i am trying to to generate a XPS Document from a WPF Control. Printing works so far, but i cannot find a way to create the XPS in landscape mode. My code to create the XPS file, mostly taken from another SO page public FixedDocument ReturnFixedDoc() { FixedDocument fixedDoc = new FixedDocument(); PageContent pageContent = new PageContent(); FixedPage fixedPage = new FixedPage(); var ctrl = new controlToPrint(); //Create first page of document fixedPage.Children.Add(ctrl); ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage); fixedDoc.Pages.Add(pageContent); //Create any other required pages here return fixedDoc; } public void SaveCurrentDocument() { // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "MyReport"; // Default file name dlg.DefaultExt = ".xps"; // Default file extension dlg.Filter = "XPS Documents (.xps)|*.xps"; // Filter files by extension // Show save file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document string filename = dlg.FileName; FixedDocument doc = ReturnFixedDoc(); XpsDocument xpsd = new XpsDocument(filename, FileAccess.Write); System.Windows.Xps.XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd); xw.Write(doc); xpsd.Close(); } } Any help is appreciated.

    Read the article

  • C# WPF Paginator printer ignoring user's printer selection

    - by Anders
    I am using the following code in my project. The print dialog shows, but it always prints on the default printer regardless of the user's selection. I have read similar topics but none of them seem to use the SerializerWriterCollator. What is the problem? PrintQueue printQueue = LocalPrintServer.GetDefaultPrintQueue(); XpsDocumentWriter xpsWriter = PrintQueue.CreateXpsDocumentWriter(printQueue); SerializerWriterCollator batchPrinter = xpsWriter.CreateVisualsCollator(); var printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { PrintTicket ticket = printDialog.PrintTicket; ticket.PageOrientation = PageOrientation.Landscape; var paginator1 = new PagePrinter(winchFlightsCount, new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight), winchFlights); var paginator2 = new PagePrinter(tugFlightCount, new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight), tugFlights); var paginator3 = new PagePrinter(selfFlightCount, new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight), selfFlights); batchPrinter.BeginBatchWrite(); for (int i = 0; i < paginator1.PageCount; i++) { batchPrinter.Write(paginator1.GetPage(i).Visual, ticket); } for (int i = 0; i < paginator2.PageCount; i++) { batchPrinter.Write(paginator2.GetPage(i).Visual, ticket); } for (int i = 0; i < paginator3.PageCount; i++) { batchPrinter.Write(paginator3.GetPage(i).Visual, ticket); } batchPrinter.EndBatchWrite(); } }

    Read the article

1