問題描述
我有一行代碼可以作為服務的一部分在本地運行,并且運行良好.
I have a line of code that I can run locally as part of a service that works perfectly fine.
sReportPath = objCrystalUtils.ExportReportToPDF("Report Name", iReportInfoID)
此代碼作為服務的一部分運行,當我通過提供數據對其進行單元測試時,它最終會構建報告并打印出來.
This code is run as a part of a service, and when I unit test it by feeding it data, it ultimately builds the report and prints it.
當我通過 ajax 調用在 .ashx 中運行完全相同的代碼時.報告已生成(我可以看到正在磁盤上創建的 pdf 文件),但沒有進行打印.
When I run the exact same piece of code inside an .ashx from an ajax call. The reports are generated (I can see the pdf files being created on disk) but the printing is not happening.
oRpt.PrintToPrinter(objReport.DefaultAutoPrint, True, 0, 0)
在這兩種情況下,都使用相同的代碼來打印報告.(objReport.DefaultAutoPrint = 0 在這兩種情況下)
In both scenarios the same code is used to print the report. (objReport.DefaultAutoPrint = 0 in both cases)
我唯一的想法是調用此方法的代碼的位置與賬單本身的位置不同.
My only thought is that the location of the code that is calling this method is in a different spot relative to the location of the bills themselves.
我要打印的打印機是安裝在我的機器上的網絡打印機,并且我運行的是 Windows 7 IIS 6.1
The printer that I'm trying to print to is a network printer intalled on my machine, and I'm running Windows 7 IIS 6.1
有什么想法嗎?
這是一個想法...如果我在本地運行一個單元測試,而我通過一個通過 IIS 運行的 Web 應用程序運行另一個,用戶 ID 和用戶對默認打印機的訪問權限是否存在差異?
Here is a thought... if I'm running one as a unit test locally and im running the other through a web app that is running via IIS, is there a difference in user id and user access to the default printer?
所以我將我的本地 ASP、IUSR 和 SYSTEM 用戶添加到打印機安全性中,并允許他們打印......沒有骰子.所以我檢查了每個用戶,它被設置為訪問并且沒有用戶被拒絕......所以我認為這有點扼殺了這種推理.
So I added my local ASP, IUSR and SYSTEM users to the printer security and allowed them to print... no dice. So I checked the EVERYONE user and it is set to access and NO users are denied... so I think that kinda kills that line of reasoning.
我更改了這篇文章的名稱,因為我不再認為該問題與 ajax 相關,因為如果我嘗試在回帖后面的代碼中執行相同的過程而不是從 ajax 調用中運行它,我仍然會得到相同的結果問題.
I changed the name of this post since I no longer think that the issue is ajax related since If I try to do the same process in code bebehind from a post back instead of running it from an ajax call i still get the same problem.
推薦答案
Patrick,對我來說,這是水晶報表的一個已知問題,通過 IIS 從正在運行的應用程序打印某個報表.
Patrick, for me it is a known issue of crystal reports, printing a certain report from a running application via IIS.
我之前遇到過同樣的問題,在我們搜索該問題后,我們得到了以下問題;
I got the same issue before, and upon our search for that issue, we got the following;
Report to be generated, exported, and then to be downloaded to client machine,
so user can print it locally (say, report will be exported as PDf file,
user can use print option of PDF reader).
這篇關于從 IIS 中的應用程序打印到服務器上的網絡打印機的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!