2016-07-26 39 views
0

我有一個使用Web窗體的ASP.NET應用程序,我試圖打印PDF。我目前使用DynamicPDF在新選項卡中生成PDF,但我們公司的動態PDF模塊不處理打印。在ASP.NET Web窗體應用程序中設置PDF頁面的紙張來源

我需要打印兩頁PDF。第一頁需要用於信封,然後第二頁需要像正常一樣打印普通紙。任何人有任何想法如何在代碼中設置紙張來源?理想情況下,我只想在我的網頁上打印,打印機知道打印第一頁信封和第二頁常規。讓我的用戶在每次打印某些內容時都會更改該設置,這是巨大的缺點。任何想法或任何可以完成此任務的工具?

謝謝!

回答

1

爲了將PDF打印到特定打印機,您需要使用DynamicPDF PrintManager for .NET產品。您可以在運行時爲每個頁面指定紙張來源,如下所示。

 InputPdf pdf = new InputPdf(@"Path for Input PDF"); 
     Printer printerObj = new Printer("Printer name"); 
     PrintJob printJobObj = new PrintJob(printerObj, pdf); 

     //Setting paper source for whole print job. 
     printJobObj.PrintOptions.PaperSource = printerObj.PaperSources[1]; 

     //Setting specific tray as paper source for first page in the print job. 
     PrintJobPage page1 = printJobObj.Pages[0]; 
     page1.PrintOptions.Inherit = false; 
     page1.PrintOptions.PaperSource = printerObj.PaperSources[2]; 

     //Setting specific tray as paper source for second page in the print job. 
     PrintJobPage page2 = printJobObj.Pages[1]; 
     page2.PrintOptions.Inherit = false; 
     page2.PrintOptions.PaperSource = printerObj.PaperSources[3]; 

     printJobObj.Print(); 

聲明:我爲開發DynamicPDF庫的公司ceTe Software工作。

相關問題