Page 1 of 1

Generating PDF From Report

Posted: Fri Dec 31, 2010 11:17 am
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.

Generating PDF From Report

Posted: Fri Dec 31, 2010 11:57 am
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.

Generating PDF From Report

Posted: Mon Jan 03, 2011 1:06 am
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.

Generating PDF From Report

Posted: Wed Jan 05, 2011 8:41 am
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.

Generating PDF From Report

Posted: Thu Jan 06, 2011 2:10 am
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.

Generating PDF From Report

Posted: Thu Jan 06, 2011 9:02 am
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.

Generating PDF From Report

Posted: Fri Jan 07, 2011 4:01 pm
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.