Link to home
Create AccountLog in
Avatar of Taitor
TaitorFlag for United States of America

asked on

Crystal Reports Viewer automatically converts to PDF when clicking the print button

A VBScript script is being called to load the Crystal Reports Viewer on a Crystal Enterprise Server and I am trying to find out if there is a way to change the default behavior of clicking the print button so that it does not automatically convert to a PDF?  

Set viewer = ObjectFactory.CreateObject("CrystalReports.CrystalReportViewer")
viewer.Name = "page"
viewer.IsOwnForm = true       
viewer.IsOwnPage = true
viewer.HasExportButton = true
viewer.HasCrystalLogo = false
viewer.HasPrintButton = true


Thanks,

Tait
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Avatar of Taitor

ASKER

I am not looking to export the report to PDF, I just want the print button in the crystal reports viewer to print and not actually convert to PDF by default.  

Thanks
If you check this out:
http://books.google.com.au/books?id=eukKHY9wjAEC&pg=PA701&lpg=PA701&dq=%22crystal+reports%22+viewer+print+to+standard+printer&source=web&ots=O8wBndQJJE&sig=6V8KUyN0V1f2c5m64BjGOwydwdg&hl=en

it states that you can *not* print to PDF by choosing to use the ActiveX control via Preferences (only if you have Internet Explorer).  Once the control is downloaded, it will display a standard print dialog.

Does that help?

Regards,

Rob.
Avatar of Taitor

ASKER

I would like to click the print button in the toolbar of the crystal reports viewer and have it bring up the print dialog box and print to a printer.  It currently brings up a number of pages options and then the report is loaded into a PDF file in Internet explorer and then I can print from the PDF.  I would rather just print right from the file in the Crystal Reports Viewer.  See attached file.

Thanks
When-I-click-the-print-icon-in-t.doc
If you go Preferences in the Viewer, can you select to use the ActiveX Control?

Rob.
Avatar of Taitor

ASKER

I don't see any ability in the viewer windo to get preferences. Would there be somewhere in the Crystal Enterprise server settings?  
thanks
Avatar of Mike McCracken
Mike McCracken

How are you running the reports?

mlmcc
Avatar of Taitor

ASKER

in a VBScript - here is the bulk of the code other than attaching parameters - thanks

Dim objectFactory
Set objectFactory = CreateObject("CrystalReports11.ObjectFactory.1")

Response.ExpiresAbsolute = Now() - 1
      
Dim viewer
'Set viewer = objectFactory.CreateObject("CrystalReports.CrystalReportInteractiveViewer")  
Set viewer = ObjectFactory.CreateObject("CrystalReports.CrystalReportViewer")
viewer.Name = "page"
viewer.IsOwnForm = true       
viewer.IsOwnPage = true
viewer.HasExportButton = true
viewer.HasCrystalLogo = false
viewer.HasPrintButton = true

Dim theReportName
theReportName = Request("ReportName")

Dim reportDir
reportDir = Server.MapPath("/crystalreports")
If InStr(theReportName,"/reports/") = 0 Then
theReportName = reportDir +"/reports/" + Request.QueryString("ReportName")
End if
viewer.URI = Request.ServerVariables("SCRIPT_NAME") + "?ReportName=" + Server.URLEncode(theReportName)

Dim clientDoc

Set clientDoc = objectFactory.CreateObject("CrystalClientDoc.ReportClientDocument")
clientDoc.Open theReportName
viewer.ReportSource = clientDoc.ReportSource
im connInfo
Set connInfo = objectFactory.CreateObject("CrystalReports.ConnectionInfo")
connInfo.UserName = userName
connInfo.Password = pwd
Dim connInfos
Set connInfos = objectFactory.CreateObject("CrystalReports.ConnectionInfos")
connInfos.add(connInfo)
viewer.EnableLogonPrompt = false
viewer.DatabaseLogonInfos = connInfos
'set DB login info END.................................................................
viewer.ProcessHttpRequest Request, Response, Null
What if you try setting the PrinterName property of the report?

clientDoc.PrintOptions.PrinterName = "HP LaserJet510"
clientDoc.PrintToPrinter(1, False, 0, 0)

http://www.crystalreportsbook.com/Crystal_Reports_Net_Ch14_2.asp

Regards,

Rob.
Avatar of Taitor

ASKER

I can't automatically default to a printer as all of the users have access to different printers throughout the building.  I know when you load the Crystal Management tools you can tell it how you want to load the report.  The setting for the viewer in the Crystal Enterprise is to load it as a ActiveX Control and it brings up the printer dialog box when I click the print button.  When I load it from the other application it does not bring up the printer dialog box.  
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account