【发布时间】:2015-09-14 17:45:14
【问题描述】:
我正在尝试将 PDF 文件附加到打印对话框,但我还没有找到方法。
我正在使用 WPF 应用程序,并且我有一些与打印相关的代码,如下所示:
private void Imprimir()
{
try
{
FixedDocument document = null;
PageContent pageContent = null;
FixedPage fixedPage = null;
PrintDialog printDlg = new PrintDialog();
if (printDlg.ShowDialog() != true)
return;
document.DocumentPaginator.PageSize = new System.Windows.Size(1400, 1450);
fixedPage.Width = document.DocumentPaginator.PageSize.Width;
fixedPage.Height = document.DocumentPaginator.PageSize.Height;
fixedPage.Margin = new Thickness(96, 96, 0, 0);
fixedPage.Children.Add(this);
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
document.Pages.Add(pageContent);
printDlg.PrintDocument(document.DocumentPaginator, "Impresion Cierre");
fixedPage.Children.Clear();
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.Message);
}
}
但是,通过这种方式,我只是打印添加到固定页面的 UI 元素。 我一直在寻找其他代码,但我一无所获。 所以,我不知道是否可以将本地存储的 PDF 文件添加到打印对话框?
感谢您的帮助...
【问题讨论】:
标签: wpf pdf printdialog