p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

crystal_reports thread: Re: CRviewer printing directly to printer without printer diaglog box ???


Message #1 by "Clara Yeung" <clarayeung427@y...> on Thu, 13 Feb 2003 09:17:28
Would you mind to tell me how to print directly? Or send me the solution..

Many thanks

> 
H> ope that someone would help me out.

> Is it posible to print directly to printer from CRViewer in ASP? 
I>  can print it out, but have not been able to find out how to print with 
o> ut getting Printer dialog box. Do i have to set up somthing on the 
w> ebserver for this. Any help would be greatly appreciated.

> Herr is my code ( i knew that the print diaglogbox appear once script 
exec 
t> he CRViewer.ViewReport. what i do not know is how to bypass it )

> <HTML>
<> HEAD>
<> TITLE>Crystal Smart Viewer</TITLE>

> </HEAD>
<> BODY bgcolor=#c6c6c6 language=vbscript onload="Page_Initialize()">
<> OBJECT ID="CRViewer"
	> CLASSID="CLSID:C4847596-972C-11D0-9567-00A0C9273C2A"
	> WIDTH=0% HEIGHT=0%
	>   
c> odebase="/viewer/activeXViewer/activexviewer.cab#Version=7,0,100,52">

> <PARAM NAME="EnableRefreshButton" VALUE=0>
<> PARAM NAME="EnableGroupTree" VALUE=0>
<> PARAM NAME="DisplayGroupTree" VALUE=0>
<> PARAM NAME="DisplayToolbar" VALUE=0>
<> PARAM NAME="EnableNavigationControls" VALUE=0>
<> PARAM NAME="EnableStopButton" VALUE=0>
<> PARAM NAME="EnableCloseButton" VALUE=0>
<> PARAM NAME="EnableProgressControl" VALUE=0>
<> PARAM NAME="EnableSelectExpertButton" VALUE=0>
<> PARAM NAME="EnablePrintButton" VALUE=0>
<> PARAM NAME="EnableExportButton" VALUE=0>
<> PARAM NAME="EnablePopupMenu" VALUE=0>
<> PARAM NAME="EnableDrillDown" VALUE=0>
<> PARAM NAME="EnableSearchControl" VALUE=0>
<> PARAM NAME="EnableAnimationControl" VALUE=0>
<> PARAM NAME="EnableZoomControl" VALUE=0>
<> /OBJECT>

> <SCRIPT LANGUAGE="VBScript">
<> !--
d> im timer
d> im printerTimer
d> im pageOne
P> ageOne = True

> Sub Page_Initialize()
	> 
s> trHref=window.location.href
	>          strval=split(strHref,"/",-1,1)
	>          strWebPath=strval(2)& "/" & strval(3) 
&>  "/trafficsystem/traffic2.rpt"  

> 
'> window.alert strwebpath

> 	On Error Resume Next
	> Dim webBroker
	> Set webBroker = CreateObject("WebReportBroker.WebReportBroker")
	> 	if ScriptEngineMajorVersion < 2 then
	> 	window.alert "IE 3.02 users on NT4 need to get the 
latest 
v> ersion of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need 
D> COM95 and latest version of VBScript, or install IE 4.01 SP1. These 
files 
a> re available at Microsoft's web site."
	> 	CRViewer.ReportName = Location.Protocol + "//" + 
strWebPath
	> else
	> 	Dim webSource
	> 	Set webSource = CreateObject
(> "WebReportSource.WebReportSource")
	> 	webSource.ReportSource = webBroker
	> 	webSource.URL = Location.Protocol + "//" + strWebPath
	> 	webSource.PromptOnRefresh = True
	> 	CRViewer.ReportSource = webSource
	> end if
	> CRViewer.ViewReport
E> nd Sub

> Sub CRViewer_DownloadFinished(downloadType)
 >    if downloadType = 1 and pageOne then
 >        PageOne = False
 >        timer = window.setTimeout("OnMyTimeOut",1000)
 >    end if
e> nd sub

> Sub OnMyTimeOut()
 >    if not CRViewer.IsBusy then
 >        window.clearTimeout(timer)
 >        'window.alert "My timeout"
 >        CRViewer.PrintReport false
 >        printerTimer = window.setTimeout("OnPrinterTimeOut", 1000)
 >    end if
e> nd sub

> Sub OnPrinterTimeOut()
 >    if not CRViewer.IsBusy then
 >        window.clearTimeout(printerTimer)
 >        window.history.back
 >    end if
e> nd sub

> 
-> ->
<> /SCRIPT>
<> /BODY>
<> /HTML>

  Return to Index