Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP: Printing over the web using CReports

Status
Not open for further replies.

nissan99

Programmer
May 21, 2002
1
0
0
US
Hi friends,
I am using crystal report 8.5. I wanted to print the report without viewing at client. I have tried all the possbile ways with the code provided by seagate. I could't print it out. Here is the code that i use!.

Any help will be appreciated....


<HEAD>
<TITLE>Seagate Crystal Smart Viewer for ActiveX</TITLE>
</HEAD>
<BODY BGCOLOR=C6C6C6>

<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=0% HEIGHT=0%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=2,2,4,37&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=0>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=0>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=0>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=0>
</OBJECT>


<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
dim timer
dim printerTimer
dim pageOne
PageOne = True
Sub window_onLoad()
Page_Initialize()
End Sub

Sub Page_Initialize
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site.&quot;
CRViewer.ReportName = Location.Href
else
Dim webSource
Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = &quot;testrep.rpt&quot;
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
'crviewer.PrintReport
End Sub

Sub CRViewer_DownloadFinished(byval downloadType)
if downloadType = 1 and PageOne then
PageOne = False
timer = window.settimeout(&quot;OnMyTimeOut&quot;,1000)
end if
end sub

Sub OnMyTimeOut()
if not CRViewer.IsBusy then
window.ClearTimeout(timer)
CRViewer.PrintReport
printerTimer = window.SetTimeOut(&quot;OnPrinterTimeOut&quot;, 1000)
end if
end sub

Sub OnPrinterTimeOut()
if not CRViewer.IsBusy then
window.ClearTimeOut(printerTimer)
window.History.Back
end if
end sub

-->
</SCRIPT>

</BODY>
</HTML>
 
This is VB code but looks like it may do what you want.

CRViewer1.ReportSource = Report
'To print directly to printer use these 2 lines
Report.PaperSource = crPRBinUpper
Report.PrintOut False, 1, False
CRViewer1.PrintReport

Hope it helps!

DavidTN
 
This is the code I used and it worked.
'The DownloadFinished event occurs when report data
'finishes loading into the report.
Sub CRViewer_DownloadFinished(byval downloadType)
if downloadType = 1 and PageOne then
PageOne = False
CRViewer.PrintReport
end if
end Sub

In the Page_Initialize sub routine I changed the following:
webSource.URL = &quot;rptServer.asp&quot;

I then used ttx to create a connection to my report.
 
Hi nissan99,

I try the code but it does not work properly. A blank page occurs and redirect it back to previous screen after a while. Do you know how to fix the problem? I would like to send the report to printer directly.

Thanks
Clara
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top