Search code examples
ajaxcrystal-reports

Printing from an application in IIS to a networked printer on server


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.

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)

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.

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

Any thoughts?

Edit:

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?

Edit:

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.

Edit:

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.


Solution

  • 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).