<FlowDocumentScrollViewer Width="1000"> <FlowDocument x:Name="FD"> <Paragraph> <Image Source="http://www.wpf-tutorial.com/images/logo.png" Width="90" Height="90" Margin="0,0,30,0" /> <Label Content="Testing Label"></Label> <TextBox Name="txtHeading" Width="150"></TextBox> <Run FontSize="120">WPF</Run> </Paragraph> <Paragraph> WPF, which stands for <Bold>Windows Presentation Foundation</Bold> , is Microsoft's latest approach to a GUI framework, used with the .NET framework. Some advantages include: </Paragraph> </FlowDocument> </FlowDocumentScrollViewer>
<FlowDocumentScrollViewer Width="1000">
<FlowDocument x:Name="FD">
<Paragraph>
<Image Source="http://www.wpf-tutorial.com/images/logo.png" Width="90" Height="90" Margin="0,0,30,0" />
<Label Content="Testing Label"></Label>
<TextBox Name="txtHeading" Width="150"></TextBox>
<Run FontSize="120">WPF</Run>
</Paragraph>
WPF, which stands for
<Bold>Windows Presentation Foundation</Bold> ,
is Microsoft's latest approach to a GUI framework, used with the .NET framework.
Some advantages include:
</FlowDocument>
</FlowDocumentScrollViewer>
if (File.Exists("printPreview.xps")) { File.Delete("printPreview.xps"); } var xpsDocument = new XpsDocument("printPreview.xps", FileAccess.ReadWrite); XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument); writer.Write(((IDocumentPaginatorSource)FD).DocumentPaginator); //Document = xpsDocument.GetFixedDocumentSequence(); // 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<Boolean> print = pDialog.ShowDialog(); if (print == true) { FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence(); pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job"); xpsDocument.Close(); }
if (File.Exists("printPreview.xps"))
{
File.Delete("printPreview.xps");
}
var xpsDocument = new XpsDocument("printPreview.xps", FileAccess.ReadWrite);
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
writer.Write(((IDocumentPaginatorSource)FD).DocumentPaginator);
//Document = xpsDocument.GetFixedDocumentSequence();
// 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<Boolean> print = pDialog.ShowDialog();
if (print == true)
FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
xpsDocument.Close();