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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to print 3 pdf reports on a web page?

Status
Not open for further replies.

MzKitty

Programmer
Oct 28, 2003
254
US
I'm using vs2008 and vb.net to build a web app. When a user hits the print button on a web page, I need to print 3 crystal reports. I am having problems with the activex printcontroll.dll, so I'm doing this with pdf's. After the first report comes up in acrobat and I print it, how do I get back to bring up the 2nd report? If I hit the back button, I go back to the original web page. Is there a way to capture the back button event to bring up the viewer for the 2nd report?

Here's my code for the 1st report:
Protected Sub PrintOffice()
saveTicketNo = intTicketNo
crReport = New RptTktOfficeCopy
crTables = crReport.Database.Tables
crViewer3.Visible = False
crViewer2.Visible = False
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue

crParameterFieldDefinitions = crReport.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("@TICKETNO")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()

crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = saveTicketNo '1st current value
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
crViewer1.Visible = True
crViewer1.Zoom(100)
' crViewer1.PrintMode = PrintMode.ActiveX
crViewer1.ReportSource = crReport

Dim exportOptions As New ExportOptions()
Dim pdfExportFormatOptions As New PdfRtfWordFormatOptions()
Dim diskDestinationOptions As New DiskFileDestinationOptions()

' Set the export format and format options
exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
pdfExportFormatOptions.FirstPageNumber = 1
pdfExportFormatOptions.LastPageNumber = 1
pdfExportFormatOptions.UsePageRange = True
exportOptions.ExportFormatOptions = pdfExportFormatOptions

' Set the disk file options.
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile
diskDestinationOptions.DiskFileName = "c:\temp\Tickets.PDF"
exportOptions.DestinationOptions = diskDestinationOptions

ExportData(crReport)

End Sub
Public Sub ExportData(ByRef oRpt As Object)
Dim fs As IO.FileStream
Dim FileSize As Long
Dim oDest As New CrystalDecisions.Shared.DiskFileDestinationOptions
Dim ExportFileName As String = "C:\Temp\Tickets.pdf"
'Server.MapPath("/") & System.Configuration.AppSettings("ExportDir") & Session.SessionID & ".pdf"
Try
oRpt.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
oRpt.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
oDest.DiskFileName = ExportFileName
oRpt.ExportOptions.DestinationOptions = oDest
Try
oRpt.Export()
Catch ex As Exception
Exit Sub
End Try

'Build Target Filename
'Send the file to the user that made the request
Response.Clear()
Response.Buffer = True
Response.AddHeader("Content-Type", "application/pdf")
fs = New IO.FileStream(ExportFileName, IO.FileMode.Open)
FileSize = fs.Length
Dim bBuffer(CInt(FileSize)) As Byte
fs.Read(bBuffer, 0, CInt(FileSize))
fs.Close()
Response.BinaryWrite(bBuffer)
Response.Flush()
Response.Close()
Catch e As Exception
End Try

End Sub

Thanks
Cathy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top