.NETGURU
Export crystal report in .net to PDF format
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-crystal' list.


Winnie Khoo
Hi All,

Does anyone know how to export crystal reports to PDF format ?
Could you pls provide me with the code ? Is there any dll which are
required ?

Thanks

Cheers
Winnie
Reply to this message...
 
    
Winnie Khoo
Hi,

I tried using the following code to export to PDF and I got the
following error. Can someone help me on this?

Code :

Dim FileSize As Long
Dim rdCrystalViewer As New ReportDocument()
Dim crReportObject As
CrystalDecisions.CrystalReports.Engine.ReportObject
Dim oExO As ExportOptions
Dim oExDo As New DiskFileDestinationOptions()

'Build Target Filename
TargetFileName = "c:\test.pdf"

'Load report
rdCrystalViewer.Load(objMapPath & "web\" & strLangCode &
"\Reports\Crystal\IN_StdRpt_PRList.rpt",
OpenReportMethod.OpenReportByTempCopy)

'Export to PDF
oExDo.DiskFileName = TargetFileName
oExO = rdCrystalViewer.ExportOptions
oExO.ExportDestinationType = ExportDestinationType.DiskFile
oExO.ExportFormatType = ExportFormatType.PortableDocFormat
oExO.DestinationOptions = oExDo
rdCrystalViewer.Export()
rdCrystalViewer.Close()

Error :

Missing parameter field current value.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details:
CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueExcepti
on: Missing parameter field current value.

Source Error:

Line 276: oExO.ExportFormatType ExportFormatType.PortableDocFormat
Line 277: oExO.DestinationOptions = oExDo
Line 278: rdCrystalViewer.Export()
Line 279: rdCrystalViewer.Close()
Line 280:

Source File:
C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb
Line: 278

Stack Trace:

[ParameterFieldCurrentValueException: Missing parameter field current
value.]
[1].[1]K(String 
, EngineExceptionErrorID 

) +482
[1].[1]G(String 

_____

, Int32 ) +57

CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInf
o(RequestContext reqContext) +1257

CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewConte
xt(ReportPageRequestContext reqContext, * viewContext) +224

CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequest
Context reqContext) +242
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() +114
CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() +74
IN_StdRpt_PRList_Preview.BindReport() in
C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:2
78
IN_StdRpt_PRList_Preview.Page_Load(Object Sender, EventArgs E) in
C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:5
9
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724

Many Thanks

Cheers
Winnie
Reply to this message...
 
    
Roshni
Hi Winnie
this is the code I use in C#
ExportOptions CrExpOpt ;

DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

String Fname ="C://Rpt.pdf" ;

DataDefinition CrDataDef;

ParameterFieldDefinitions PFDefs ;

ParameterField crParameterField1 = new ParameterField();

ParameterField crParameterField2 = new ParameterField();

ParameterValues CrParaVals1 = new ParameterValues();

ParameterValues CrParaVals2 = new ParameterValues();

ParameterValues CrDocParaVals = new ParameterValues();

CrDataDef = CR1.DataDefinition;

PFDefs = CrDataDef.ParameterFields;

crParameterFields = CRV.ParameterFieldInfo;

crParameterField1 = crParameterFields[0];

crParameterField2 = crParameterFields[1];

CrParaVals1 =crParameterField1.CurrentValues;

CrParaVals2 =crParameterField2.CurrentValues;

CR1.DataDefinition.ParameterFields[0].ApplyCurrentValues(CrParaVals1);

CR1.DataDefinition.ParameterFields[1].ApplyCurrentValues(CrParaVals2);

diskOpts.DiskFileName = Fname;

CrExpOpt = CR1.ExportOptions;

CrExpOpt.DestinationOptions = diskOpts;

CrExpOpt.ExportDestinationType = ExportDestinationType.DiskFile;

CrExpOpt.ExportFormatType = ExportFormatType.PortableDocFormat;

CR1.Export();

Response.ClearContent();

Response.ClearHeaders();

Response.ContentType ="application/pdf";

Response.WriteFile(Fname);

Response.Flush();

Response.Close();

System.IO.File.Delete(Fname);

The report can be printed using the print button in the pdf screen

Roshni

----- Original Message -----
From: Winnie Khoo
To: ngfx-crystal
Sent: Friday, July 26, 2002 6:07 AM
Subject: [ngfx-crystal] Export crystal report in .net to PDF format

Hi,

I tried using the following code to export to PDF and I got the following error. Can someone help me on this?

Code :

Dim FileSize As Long

Dim rdCrystalViewer As New ReportDocument()

Dim crReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject

Dim oExO As ExportOptions

Dim oExDo As New DiskFileDestinationOptions()

'Build Target Filename

TargetFileName = "c:\test.pdf"

'Load report

rdCrystalViewer.Load(objMapPath & "web\" & strLangCode & "\Reports\Crystal\IN_StdRpt_PRList.rpt", OpenReportMethod.OpenReportByTempCopy)

'Export to PDF

oExDo.DiskFileName = TargetFileName

oExO = rdCrystalViewer.ExportOptions

oExO.ExportDestinationType = ExportDestinationType.DiskFile

oExO.ExportFormatType = ExportFormatType.PortableDocFormat

oExO.DestinationOptions = oExDo

rdCrystalViewer.Export()

rdCrystalViewer.Close()

Error :

Missing parameter field current value.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.

Source Error:

Line 276: oExO.ExportFormatType = ExportFormatType.PortableDocFormat
Line 277: oExO.DestinationOptions = oExDo
Line 278: rdCrystalViewer.Export()
Line 279: rdCrystalViewer.Close()
Line 280:

Source File: C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb Line: 278

Stack Trace:

[ParameterFieldCurrentValueException: Missing parameter field current value.]
[1].[1]K(String 
, EngineExceptionErrorID 
) +482
[1].[1]G(String 
------------------------------------------------------------------------
, Int32 ) +57
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInfo(RequestContext reqContext) +1257
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewContext(ReportPageRequestContext reqContext, * viewContext) +224
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) +242
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() +114
CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() +74
IN_StdRpt_PRList_Preview.BindReport() in C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:278
IN_StdRpt_PRList_Preview.Page_Load(Object Sender, EventArgs E) in C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:59
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724

Many Thanks

Cheers

Winnie

| [ngfx-crystal] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-crystal.asp = JOIN/QUIT
Reply to this message...
 
    
Roshni
Hi Winnie
You need to set parameters again before exporting
in C# I use param[] arraylist to hold the parameters as this function sets parameters for different reports
Following is the code i Used
ParameterFields crParameterFields = new ParameterFields();

ParameterField crParameterField = null;;

ParameterDiscreteValue crParameterDiscreteValue = null;

crParameterFields = PdfCRV.ParameterFieldInfo;

DataDefinition CrDataDef;

ParameterFieldDefinitions PFDefs ;

int count = param.Count;

CrDataDef = rep.DataDefinition;

PFDefs = CrDataDef.ParameterFields;

for(int i = 0;i< count; i++)

{

crParameterField = new ParameterField();

crParameterDiscreteValue = new ParameterDiscreteValue();

ParameterValues CrParaVals = new ParameterValues();

crParameterField = crParameterFields[i];

crParameterDiscreteValue.Value =param[i];

crParameterField.CurrentValues.Add(crParameterDiscreteValue);

CrParaVals =crParameterField.CurrentValues;

rep.DataDefinition.ParameterFields[i].ApplyCurrentValues(CrParaVals);

}

PdfCRV.ParameterFieldInfo = crParameterFields;

----- Original Message -----
From: Winnie Khoo
To: ngfx-crystal
Sent: Friday, July 26, 2002 6:07 AM
Subject: [ngfx-crystal] Export crystal report in .net to PDF format

Hi,

I tried using the following code to export to PDF and I got the following error. Can someone help me on this?

Code :

Dim FileSize As Long

Dim rdCrystalViewer As New ReportDocument()

Dim crReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject

Dim oExO As ExportOptions

Dim oExDo As New DiskFileDestinationOptions()

'Build Target Filename

TargetFileName = "c:\test.pdf"

'Load report

rdCrystalViewer.Load(objMapPath & "web\" & strLangCode & "\Reports\Crystal\IN_StdRpt_PRList.rpt", OpenReportMethod.OpenReportByTempCopy)

'Export to PDF

oExDo.DiskFileName = TargetFileName

oExO = rdCrystalViewer.ExportOptions

oExO.ExportDestinationType = ExportDestinationType.DiskFile

oExO.ExportFormatType = ExportFormatType.PortableDocFormat

oExO.DestinationOptions = oExDo

rdCrystalViewer.Export()

rdCrystalViewer.Close()

Error :

Missing parameter field current value.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.

Source Error:

Line 276: oExO.ExportFormatType = ExportFormatType.PortableDocFormat
Line 277: oExO.DestinationOptions = oExDo
Line 278: rdCrystalViewer.Export()
Line 279: rdCrystalViewer.Close()
Line 280:

Source File: C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb Line: 278

Stack Trace:

[ParameterFieldCurrentValueException: Missing parameter field current value.]
[1].[1]K(String 
, EngineExceptionErrorID 
) +482
[1].[1]G(String 
------------------------------------------------------------------------
, Int32 ) +57
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInfo(RequestContext reqContext) +1257
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewContext(ReportPageRequestContext reqContext, * viewContext) +224
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext) +242
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() +114
CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() +74
IN_StdRpt_PRList_Preview.BindReport() in C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:278
IN_StdRpt_PRList_Preview.Page_Load(Object Sender, EventArgs E) in C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:59
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724

Many Thanks

Cheers

Winnie

| [ngfx-crystal] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/ngfx-crystal.asp = JOIN/QUIT
Reply to this message...
 
    
Winnie Khoo
Hi Roshni,

Thanks for your reply. What is CR1 declared as in this code ?

Cheers
Winnie

-----Original Message-----
From: Roshni [mailto:Click here to reveal e-mail address]
Sent: 26 July, 2002 9:44 PM
To: ngfx-crystal
Subject: [ngfx-crystal] Re: Export crystal report in .net to PDF format

Hi Winnie
this is the code I use in C#
ExportOptions CrExpOpt ;
DiskFileDestinationOptions diskOpts = new
DiskFileDestinationOptions();
String Fname ="C://Rpt.pdf" ;

DataDefinition CrDataDef;
ParameterFieldDefinitions PFDefs ;

ParameterField crParameterField1 = new ParameterField();
ParameterField crParameterField2 = new ParameterField();
ParameterValues CrParaVals1 = new ParameterValues();
ParameterValues CrParaVals2 = new ParameterValues();
ParameterValues CrDocParaVals = new ParameterValues();
CrDataDef = CR1.DataDefinition;
PFDefs = CrDataDef.ParameterFields;
crParameterFields = CRV.ParameterFieldInfo;
crParameterField1 = crParameterFields[0];
crParameterField2 = crParameterFields[1];
CrParaVals1 =crParameterField1.CurrentValues;
CrParaVals2 =crParameterField2.CurrentValues;

CR1.DataDefinition.ParameterFields[0].ApplyCurrentValues(CrParaVals1);

CR1.DataDefinition.ParameterFields[1].ApplyCurrentValues(CrParaVals2);

diskOpts.DiskFileName = Fname;
CrExpOpt = CR1.ExportOptions;
CrExpOpt.DestinationOptions = diskOpts;
CrExpOpt.ExportDestinationType = ExportDestinationType.DiskFile;
CrExpOpt.ExportFormatType = ExportFormatType.PortableDocFormat;

CR1.Export();

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType ="application/pdf";
Response.WriteFile(Fname);
Response.Flush();
Response.Close();
System.IO.File.Delete(Fname);

The report can be printed using the print button in the pdf screen
Roshni
----- Original Message -----
From: Winnie <mailto:Click here to reveal e-mail address> Khoo
To: ngfx-crystal <mailto:Click here to reveal e-mail address>
Sent: Friday, July 26, 2002 6:07 AM
Subject: [ngfx-crystal] Export crystal report in .net to PDF format

Hi,

I tried using the following code to export to PDF and I got the
following error. Can someone help me on this?

Code :

Dim FileSize As Long
Dim rdCrystalViewer As New ReportDocument()
Dim crReportObject As
CrystalDecisions.CrystalReports.Engine.ReportObject
Dim oExO As ExportOptions
Dim oExDo As New DiskFileDestinationOptions()

'Build Target Filename
TargetFileName = "c:\test.pdf"

'Load report
rdCrystalViewer.Load(objMapPath & "web\" & strLangCode &
"\Reports\Crystal\IN_StdRpt_PRList.rpt",
OpenReportMethod.OpenReportByTempCopy)

'Export to PDF
oExDo.DiskFileName = TargetFileName
oExO = rdCrystalViewer.ExportOptions
oExO.ExportDestinationType = ExportDestinationType.DiskFile
oExO.ExportFormatType = ExportFormatType.PortableDocFormat
oExO.DestinationOptions = oExDo
rdCrystalViewer.Export()
rdCrystalViewer.Close()

Error :

Missing parameter field current value.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details:
CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueExcepti
on: Missing parameter field current value.

Source Error:

Line 276: oExO.ExportFormatType ExportFormatType.PortableDocFormat
Line 277: oExO.DestinationOptions = oExDo
Line 278: rdCrystalViewer.Export()
Line 279: rdCrystalViewer.Close()
Line 280:

Source File:
C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb
Line: 278

Stack Trace:

[ParameterFieldCurrentValueException: Missing parameter field current
value.]
[1].[1]K(String 
, EngineExceptionErrorID

) +482
[1].[1]G(String 

_____

, Int32 ) +57

CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInf
o(RequestContext reqContext) +1257

CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewConte
xt(ReportPageRequestContext reqContext, * viewContext) +224

CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequest
Context reqContext) +242
CrystalDecisions.CrystalReports.Engine.FormatEngine.Export() +114
CrystalDecisions.CrystalReports.Engine.ReportDocument.Export() +74
IN_StdRpt_PRList_Preview.BindReport() in
C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:2
78
IN_StdRpt_PRList_Preview.Page_Load(Object Sender, EventArgs E) in
C:\iTech\Plantware\Web\include\reports\IN_StdRpt_PRListPreview.aspx.vb:5
9
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724

Many Thanks

Cheers
Winnie
| [ngfx-crystal] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-crystal.asp = JOIN/QUIT
| [ngfx-crystal] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-crystal.asp = JOIN/QUIT
Reply to this message...
 
    
Lee Chin How
(Type your message here)
Hi, I have succeeded export crystal report to PDF file, but the "Date" field was "Unable" to display in the PDF File, what's the problem? Is there anybody can help me?

--------------------------------
From: Lee Chin How
Reply to this message...
 
    
Josh Wilson
I experienced this same issue and was able to resolve it by downloading Crystal Reports 9 SP3 at the following link:

http://support.businessobjects.com/fix/hot/si75/default.asp?ref=default.asp_wwwjump

--------------------------------
From: Josh Wilson
Reply to this message...
 
 
System.EventArgs
System.IO.File
System.Web.UI.Control
System.Web.UI.Page




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification