[英]How to achieve same print functionality of Silverlight into WPF?
我們正在將 SilverLight 應用程序遷移到 WPF,在我們的打印應用程序中,我們使用了 System.Windows.Printing。 相同的命名空間在 WPF 中不可用,它具有 System.Drawing.Printing 命名空間,因為此現有功能無法按預期工作。 我們需要為此編寫新的打印。 有什么方法可以在不編寫新代碼的情況下實現相同的目標。
在 WPF 中使用打印機選擇打印文件的實現
private static void PrintFile(string pathToFile)
{
PrintDialog pDialog = new PrintDialog();
bool? print = pDialog.ShowDialog();
if (print == true)
{
string printerName = pDialog.PrintQueue.FullName;
Process p = new Process
{
StartInfo = new ProcessStartInfo()
{
Arguments = "\"" + printerName + "\"",
CreateNoWindow = true,
Verb = "PrintTo",
FileName = pathToFile
}
};
p.Start();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.