我正在创建一个 WPF 应用程序,我想使用 spire.doc 打印一个 word 文档。我阅读了一些教程,他们说我应该使用这段代码。
//Create Word document.
Document document = new Document();
document.LoadFromFile(@"..\..\..\..\..\..\Data\Template.docx");
//Print doc file.
System.Windows.Forms.PrintDialog dialog = new System.Windows.Forms.PrintDialog();
dialog.AllowCurrentPage = true;
dialog.AllowSomePages = true;
dialog.UseEXDialog = true;
try
{
document.PrintDialog = dialog;
dialog.Document = document.PrintDocument;
dialog.Document.Print();
}
但它不起作用,因为document.PrintDialog
type 是System.Windows.Controls.PrintDialog
并且我收到此错误:
无法将类型“System.Windows.Forms.PrintDialog”隐式转换为“System.Windows.Controls.PrintDialog”