Dear All,
This is my first question in C# Corner. Please apologize for any inconvenience.
Iam using WPF and XPS to print content from a FlowDocument.
XAML :
<FlowDocumentScrollViewer Width="1000">
<FlowDocument x:Name="FD">
<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>
<Bold>Windows Presentation Foundation</Bold> ,
is Microsoft's latest approach to a GUI framework, used with the .NET framework.
</FlowDocumentScrollViewer>
C# Code to Print :
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();
FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
It works fine expect the Final output is by splitting the Page into 2 Columns. Need help in making the page layout in single coulmn.