我正在WPF中构建一个演示应用程序,这对我来说是新的.我目前正在FlowDocument中显示文本,需要打印它.
我正在使用的代码如下所示:
PrintDialog pd = new PrintDialog();
fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWidth;
fd.PagePadding = new Thickness(50);
fd.ColumnGap = 0;
fd.ColumnWidth = pd.PrintableAreaWidth;
IDocumentPaginatorSource dps = fd;
pd.PrintDocument(dps.DocumentPaginator, "flow doc");
Run Code Online (Sandbox Code Playgroud)
fd是我的FlowDocument,现在我使用默认打印机而不是允许用户指定打印选项.它工作正常,除了在文档打印后,屏幕上显示的FlowDocument已更改为使用我指定的设置进行打印.
我可以通过在打印后手动重置所有内容来解决这个问题,但这是最好的方法吗?我打印之前是否应该复制FlowDocument?或者我应该考虑另一种方法吗?