Generating PDF From Report

Stimulsoft Reports.NET discussion
Post Reply
BatutaBunsing
Posts: 7
Joined: Thu Dec 30, 2010 11:36 am

Generating PDF From Report

Post by BatutaBunsing »

Hi,

When I try the following code to generate a PDF into a file directly from the report, I am unable to open the PDF, saying that the PDF cannot be opened because it does not have any pages.

Here's the code (VB.Net)

Code: Select all

Dim pdfSettings As New StiPdfExportSettings
Dim pdfExport As New StiPdfExportService

Dim strNewGUIId As String = System.Guid.NewGuid.ToString & ".pdf"
Dim strFileName As String = Server.MapPath("reports") & "\" & strNewGUIId
pdfExport.ExportPdf(rpt2, strFileName)
The PDF file is being generated from the specified folder but it cannot be opened.

Any advice highly appreciated. Thank you.
BatutaBunsing
Posts: 7
Joined: Thu Dec 30, 2010 11:36 am

Generating PDF From Report

Post by BatutaBunsing »

Was able to make some headway to this.

Here's the code:

Code: Select all

'For the DataSet
Dim ds As DataSet = New ReportData
Dim dt As DataTable = ds.Tables("Orders")

For x As Integer = 0 To 5
  Dim drow As DataRow = dt.NewRow
  drow("Column1") = x.ToString
  drow("Column2") = System.Guid.NewGuid.ToString
  dt.Rows.Add(drow)
Next

Dim rpt2 As New StiReport
rpt2.Load(Server.MapPath("reports\TestReport.mrt"))
rpt2.RegData(ds)

Dim pdfSettings As New StiPdfExportSettings
Dim pdfExport As New StiPdfExportService

rpt2.Compile()

Dim strNewGUIId As String = System.Guid.NewGuid.ToString & ".pdf"
Dim strFileName As String = Server.MapPath("reports") & "\" & strNewGUIId

pdfExport.ExportPdf(rpt2, strFileName)
I am populating the report from a dataset, since I am passing some serialized data from the client onto the server.

The PDF being generated can now be opened, BUT, no data is on the PDF. The report viewer shows that there is data (based from populating with the dataset).

Is there any setting or method call which I am missing?

Thanks.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Generating PDF From Report

Post by Ivan »

Hello,

We couldn't reproduce this issue without data.
Can you please send us a simple test project, which reproduces the issue?

Thank you.
BatutaBunsing
Posts: 7
Joined: Thu Dec 30, 2010 11:36 am

Generating PDF From Report

Post by BatutaBunsing »

Ivan wrote:Hello,

We couldn't reproduce this issue without data.
Can you please send us a simple test project, which reproduces the issue?

Thank you.
From the codes I have provided, the data is being fed to the report.

Code: Select all

For x As Integer = 0 To 5
  Dim drow As DataRow = dt.NewRow
  drow("Column1") = x.ToString
  drow("Column2") = System.Guid.NewGuid.ToString
  dt.Rows.Add(drow)
Next
I have simply created a dataset, adding a datatable named "DataSource". The datatable contains two columns, named col1 and col2.

From the report, I have set the Data Sources to the data table, providing the name "DataSource" and defining two columns with the same columns as with the datatable.

The report is being populated properly, but when I try to run the PDF export, it is unable to capture the data on the report.

I think I may be missing a declaration or something.

I could send the report if needed.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Generating PDF From Report

Post by Ivan »

Hello,

We couldn't reproduce this issue without report and data.
Please send us a simple test project, which reproduces the issue.

Thank you.
BatutaBunsing
Posts: 7
Joined: Thu Dec 30, 2010 11:36 am

Generating PDF From Report

Post by BatutaBunsing »

Ivan wrote:Hello,

We couldn't reproduce this issue without report and data.
Please send us a simple test project, which reproduces the issue.

Thank you.
Attached is the report I am using.

For the dataset, it should be fairly easy. Simply create a new Dataset and define a datatable for it.

Then using the scripts I have provided above, you should be able to reproduce the problem.
Attachments
773.TestReport.mrt
(6.21 KiB) Downloaded 178 times
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Generating PDF From Report

Post by Jan »

Hello,
BatutaBunsing wrote:Was able to make some headway to this.

Here's the code:
Try to call Render method of report after Compile method. Export method does not call Render method of report automatically.

Thank you.
Post Reply