2012-02-03 76 views
0

我使用PdfSharp/MigraDoc在應用程序中創建和查看文檔。從WPF應用程序打印MigraDoc文檔

我使用WPF版本,因爲我需要WPF文檔查看器。現在我想打印文檔(可從DocumentViewer中運行),但出於某種原因,當我嘗試打印自己時,我只能看到空白頁面。

我使用此代碼打印:

MigraDocPrintDocument printDocument = new MigraDocPrintDocument(); 
printDocument.Renderer = new DocumentRenderer(druck.GetDruck()); 
printDocument.Renderer.PrepareDocument(); 
printDocument.Print(); 

什麼我需要做的打印從WPF(從WinForms的這個工作很好,但我需要WPF爲的DocumentViewer)。

回答

2

這是MigraDoc 1.31的已知錯誤:只有在使用GDI +版本時,打印纔有效。
作爲解決方法,您可以嘗試使用兩種版本 - WPF構建預覽版,GDI +構建版直接打印。

+0

但是使用來自同一個程序集的兩個版本是非常棘手的,因爲它們共享命名空間 - 不是嗎? – Sam 2012-02-06 09:01:46

+1

您不必在同一個程序集中同時使用兩個版本 - 創建一個使用GDI +的新PrintHelper程序集並將文檔傳遞給作爲MigraDoc DDL字符串。另見:http://www.pdfsharp.net/wiki/MigraDocDDL.ashx – 2012-02-06 14:56:44