Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2004, 07:51 AM
Authorized User
 
Join Date: Sep 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zouky
Default how to create the print layout on the web app?

dear all expert

what and how should i do to letting my web application can print adequately accordingly. where and how should i can customizing the print page layout?? (in either .NET framework or CR10)

let say i would like ot devide the A4 paper size printing it into 1/3 layout...so it should come out 3 partition..

thank you!!


 
Old October 18th, 2004, 11:54 AM
Authorized User
 
Join Date: Oct 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'm working at trying to get printing to work out properly myself. In order to print it out, it must be exported first into something such as a *.pdf file. I've got code that is working for that, but I'd like to have a print button where it would export into *.pdf, then call Adobe Acrobat and open the exported file there for printing.

Here's my code that is exporting the report into *.pdf:

    Sub PrintReport()
        ' This subroutine exports a file into Adobe Acrobat in order to print it.
        ' ********************************
        'Check to see if the application directory has a subdirectory called "C:\ExportFileName\".
        'If not, create the directory since exported files will be placed here.
        'This uses the Directory class of the System.IO namespace.
        Dim ExportPath As String
        ExportPath = "C:\ExportFileName\"
        If Directory.Exists(ExportPath) = False Then
            Directory.CreateDirectory("C:\ExportFileName")
        End If

        ' ********************************
        'Set the time for the file name in order to affix it the the created file.
        Dim DateTimeNow As DateTime
        Dim Yr As Int16
        Dim Yr2 As String
        Dim Mth As Int16
        Dim mth2 As String
        Dim Dy As Int16
        Dim dy2 As String
        Dim Hr As Int16
        Dim hr2 As String
        Dim Mn As Int16
        Dim mn2 As String
        Dim strDateTimeNow As String

        DateTimeNow = Now()
        Yr = Year(DateTimeNow)
        Yr2 = Yr.ToString
        Mth = Month(DateTimeNow)
        If Mth <= 9 Then
            mth2 = "0" + Mth.ToString
        Else
            mth2 = Mth.ToString
        End If
        Dy = Day(DateTimeNow)
        If Dy <= 9 Then
            dy2 = "0" + Dy.ToString
        Else
            dy2 = Dy.ToString
        End If
        Hr = Hour(DateTimeNow)
        If Hr <= 9 Then
            hr2 = "0" + Hr.ToString
        Else
            hr2 = Hr.ToString
        End If
        Mn = Minute(DateTimeNow)
        If Mn <= 9 Then
            mn2 = "0" + Mn.ToString
        Else
            mn2 = Mn.ToString
        End If
        strDateTimeNow = Yr2 + mth2 + dy2 + hr2 + mn2

        ' ********************************
        ' this allows me to login to my file. If no logon is needed, skip this step.
        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table
        Dim TableCounter
        Dim crReportDocument As New ReportDocument

'ReportFullPathName is a variable I created that holds the path and name of the report file.
        crReportDocument.Load(ReportFullPathName)

        'Set the ConnectionInfo properties for logging on to the Database

        'If you are using ODBC, this should be the DSN name NOT the physical server name. If
        'you are NOT using ODBC, this should be the physical server name

        With crConnectionInfo
            .ServerName = "MRI_Dwh_Dev"

            'If you are connecting to Oracle there is no DatabaseName. Use an empty string.
            'For example, .DatabaseName = ""

            .DatabaseName = ""
            .UserID = strUID
            .Password = strPWD
        End With

        'This code works for both user tables and stored procedures. Set the CrTables to the Tables collection
        'of the report

        CrTables = crReportDocument.Database.Tables

        'Loop through each table in the report and apply the LogonInfo information

        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)

        Next

        crDiskFileDestinationOptions = New DiskFileDestinationOptions
        crExportOptions = crReportDocument.ExportOptions

        'Export to PDF

                'append a filename to the export path and set this file as the filename property for
                'the DestinationOptions class
                crDiskFileDestinationOptions.DiskFileName = ExportPath + ReportName + strDateTimeNow + ".pdf"

                'set the required report ExportOptions properties
                With crExportOptions
                    .DestinationOptions = crDiskFileDestinationOptions
                    .ExportDestinationType = ExportDestinationType.DiskFile
                    .ExportFormatType = ExportFormatType.PortableDocFormat
                End With

        'Once the export options have been set for the report, the report can be exported. The Export command
        'does not take any arguments
        Try
            ' Export the report
            crReportDocument.Export()
            'Response.WriteFile(ExportPath + ReportName + strDateTimeNow + ".pdf")

        Catch err As Exception
            Response.Write("<BR>")
            Response.Write(err.Message.ToString)
        End Try

    End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a VB.Net app to a web app? furjaw VB.NET 3 September 24th, 2007 12:27 PM
Can c++ be used to create a powerful web app? larryfran C++ Programming 1 January 25th, 2006 06:52 AM
Can C++ be used to create a powerful web app? larryfran Visual C++ 1 January 25th, 2006 06:44 AM
Print the layout of a table in Access rylemer Access 2 August 31st, 2004 12:55 PM
Create C# Web App Visual Studio on remote IIS 6 lange Classic ASP Professional 0 July 31st, 2004 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.