Solved

Vb.net Crystal Report Export to .PDF

Posted on 2008-10-09
5
1,323 Views
Last Modified: 2012-05-05
All,
I currently have a block of code below that I created to load a crystal report into a local viewer and pass the required parameters to the crystal report to display the parameters. I was wondering of a way to not load the report into the viewer and automatically export it to a .pdf document. I still need to pass the parameters to the document also. Any help would be greatly appreciated.

Crystal report load:
'Declare new variable to instance of the specified crystal report.

            Me.CrystalReportViewer1.ReportSource = "C:\FrozenDessertVB\fdinspectionreport.rpt"
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
            Dim p_inspection As New ParameterField
            p_inspection.Name = "Inspection"
            Dim p_inspection_Value As New ParameterDiscreteValue
            p_inspection_Value.Value = My.Settings.Inspection_Identity
            p_inspection.CurrentValues.Add(p_inspection_Value)
            ParamFields.Add(p_inspection)
0
Comment
Question by:jpadkins49
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 22681731
Use the reportdocument object and replace this:
Me.CrystalReportViewer1.ReportSource = "C:\FrozenDessertVB\fdinspectionreport.rpt"
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo

with this:

Dim cr As New CrystalDecisions.CrystalReports.Engine.ReportDocument
cr.load("C:\FrozenDessertVB\fdinspectionreport.rpt")
Dim ParamFields As ParameterFields = cr.ParameterFields

if you need to view it as well:
CrystalReportViewer1.Reportsource = cr
 
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22683463
0
 
LVL 1

Author Comment

by:jpadkins49
ID: 22690929
UnifiedIS:
Is there another step that I need to take to automatically export the document to .pdf. I will try this when I return home later and see.
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 total points
ID: 22701924
After adding your parameters, use cr.ExporttoDisk

cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, filepath)
0
 
LVL 1

Author Closing Comment

by:jpadkins49
ID: 31507818
This solution worked like a charm. Sorry it took so long for me to respond.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question