![](/img/trans.png)
[英]Print Word Document using a virtual PDF printer from C# programmatically and silently
[英]Print PDF To Printer Programmatically C#
我有一個將SSRS報告以PDF格式寫入文件目錄的應用程序,並且我希望每次將報告添加到文件夾中以將其打印到特定的網絡打印機時使用。 使用SQL SSRS Web服務生成報告。
該文件夾和應用程序位於服務器上,我無法使用Adobe的靜默打印來完成此操作。 有人有建議嗎?
謝謝。
您可以嘗試以原始格式發送文檔,或者可以使用TcpClient將文件轉換為流並將其發送到打印機 。
意識到我沒有回答這個問題,並想進行跟進,以防其他人遇到此問題。 我最終使用了從這里找到的答案中的代碼...
我能夠使用Web服務創建報告,並將其放入報告查看器中,然后簡單地將報告和要打印的打印機作為參數傳遞給上面的代碼,並為我處理打印。 我唯一要做的就是擴展功能,以接受打印機名稱作為參數,並使用assign that作為我要打印到的指定打印機。
這是一些示例代碼,以防有人想看到我使用的一般流程。
List<ReportParameter> reportparms = new List<ReportParameter>();
ServerReport rpt = new ServerReport();
reportparms.Add(new ReportParameter("param1", param1));
rpt.ReportServerUrl = reportserver;
rpt.ReportPath = myReportPath;
rpt.SetParameters(reportparms);
//I created a class "ReportPrintDocument" for the code from the question linked above.
ReportPrintDocument rdp = new ReportPrintDocument(rpt, myPrinter);
rdp.PrinterSettings.PrinterName = ps.Printer;
if (p.PrinterSettings.IsValid)
{
rdp.Print();
}
到處都有其他邏輯,但這是完成任務的基本思想。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.