Printing an xps fixed document
-
I have an WPF XAML application where I need to capture a portion of the page and send it to the printer. I have gone through the Microsoft print dialog control reference and see how I can save an xps formatted document then load it into the print dialog and send it to the printer. Now I have read an article indicating that all I have to do is create a FixedDocument and bind my values to it's datacontext and then save the completed FixedDocument, reload it and send it to the pring dialog as an xps file which is what I want. The fixed page XAML is shown below:
-
I have an WPF XAML application where I need to capture a portion of the page and send it to the printer. I have gone through the Microsoft print dialog control reference and see how I can save an xps formatted document then load it into the print dialog and send it to the printer. Now I have read an article indicating that all I have to do is create a FixedDocument and bind my values to it's datacontext and then save the completed FixedDocument, reload it and send it to the pring dialog as an xps file which is what I want. The fixed page XAML is shown below:
I came up with an easy solution. Because I am only printing the XAML page that is being displayed, except for a few areas that I can collapse, here is what I did. On the XAML page it has a print stackpanel with the print button and header text I need to remove. After collapsing these elements I just use the PrintDialog PrintVisual(MainPageGrid, "Title"); method.