我使用以下代码打印FlowDocument
:
PrintDialog dialog = new PrintDialog();
var value = dialog.ShowDialog();
if (value.HasValue && value.Value == true)
{
XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(dialog.PrintQueue);
PageImageableArea imageArea = dialog.PrintQueue.GetPrintCapabilities().PageImageableArea;
PrintTicket ticket = dialog.PrintTicket;
if (writer != null && imageArea != null)
{
DocumentPaginator paginator = (doc as IDocumentPaginatorSource).DocumentPaginator;
paginator.PageSize = new Size((double)ticket.PageMediaSize.Width, (double)ticket.PageMediaSize.Height);
var padding = doc.PagePadding;
doc.PagePadding = new Thickness(
Math.Max(imageArea.OriginWidth, padding.Left),
Math.Max(imageArea.OriginHeight, padding.Top),
Math.Max((double)ticket.PageMediaSize.Width - (double)(imageArea.OriginWidth + imageArea.ExtentWidth), padding.Right),
Math.Max((double)ticket.PageMediaSize.Height - (double)(imageArea.OriginHeight + imageArea.ExtentHeight), padding.Bottom));
doc.ColumnWidth = double.PositiveInfinity;
// Send DocumentPaginator to the printer.
writer.Write(paginator);
}
}
现在我想在不同的页面上打印一个单独的doc块,我该怎么做?