I wrote a class that inherits from DocumentViewer
public class MyDocumentViewer : DocumentViewer
{
public bool Landscape{ get; set; }
protected override void OnPrintCommand()
{
// get a print dialog, defaulted to default printer and default printer's preferences.
PrintDialog printDialog = new PrintDialog();
printDialog.PrintQueue = System.Printing.LocalPrintServer.GetDefaultPrintQueue();
printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket;
// get a reference to the FixedDocumentSequence for the viewer.
FixedDocumentSequence docSeq = this.Document as FixedDocumentSequence;
// set the default page orientation based on the desired output.
if(!Landscape)
printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
else
printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape;
if (printDialog.ShowDialog() == true)
{
// set the print ticket for the document sequence and write it to the printer.
docSeq.PrintTicket = printDialog.PrintTicket;
XpsDocumentWriter writer = System.Printing.PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
writer.WriteAsync(docSeq, printDialog.PrintTicket);
}
}
protected override void OnManipulationBoundaryFeedback(System.Windows.Input.ManipulationBoundaryFeedbackEventArgs e)
{
base.OnManipulationBoundaryFeedback(e);
e.Handled = true;
}
}
I use this viewer inter alia to show XPS file with bookmarks, and after navigating to a bookmark, the document will be reloaded in the standard DocumentViewer. I know how to change the style after reloading but I cannot find how to resolve this problem.
Is it possible to change default viewer for FixedDocument ?
If not, maybe somebody knows another way to resolve it.