|
|
Questions and answers for Controls PrintDialog.
|
59. Controls PrintDialog
|
| 59.1 How can I
create and display a PrintDialog ?
|
| 59.2 How do I
display the PrintPreview as a maximized window and control it's zooming ?
|
59.1 How can I create and display a PrintDialog ?
|
|
This can be done using the following code.
|
[C#]
public void InvokePrint(object sender, RoutedEventArgs e)
{
// Create the print dialog object and set options
PrintDialog pDialog = new PrintDialog();
pDialog.PageRangeSelection = PageRangeSelection.AllPages;
pDialog.UserPageRangeEnabled = true;
// Display the dialog. This returns true if the user presses the Print button.
Nullable print = pDialog.ShowDialog();
if (print == true)
{
XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps",
FileAccess.ReadWrite);
FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
}
}
|
59.2 How do I display the PrintPreview as a maximized window and control it's
zooming ?
|
|
You can use the "WindowState" property of the "PrintPreviewDialog" class to
maximize the PrintPreview window. To handle zooming, the PrintPreview Dialog
uses a property of the PrintPreview control. PrintPreviewControl contains a
"Zoom" property that allows you to set the zoom factor of the PrintPreview.
|
|