Reporting Architecture Issue

Stimulsoft Reports.NET discussion
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Reporting Architecture Issue

Post by fkmfkm »

Hi,

I could not find any documentation about this, so I post it here...

For eg. I have a aspx Purchase Order Entry. Upon completing the data entry on this page, the user wish to print this PO. Normally I will have print button on this page. Upon clicking it, an PDF will open up in a new browser showing this PO.

Where should I put this report in ? What would the code in the button look like ?

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Reporting Architecture Issue

Post by Edward »

Hi

Please let us know your task in detail. Do you need to send parameters from the aspx page into the report and then to print it directly by pressing just a button on the client's computer?

Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Reporting Architecture Issue

Post by fkmfkm »

I already have all the data required on my data entry aspx page. I have it in my custom object. Some are single data like Creditors ID, Name, Address and the rest are repeating purchase detail items (Item ID, Description, Qty, Price).

So I need to pass all this data to my report and have the report appears as another web page (could be PDF, Word or HTML)
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Reporting Architecture Issue

Post by Edward »

Please use the following code to export rendered report in Pdf:

report.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, "D:\\MyFile.pdf");

To render report in pdf, please use the following:
Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report, false)

if you need a window with asking about saving the Pdf, please use the following command:

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report)

Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Reporting Architecture Issue

Post by fkmfkm »

I dont want the window asking to save the pdf ..

I want a new window showing the pdf ? how to do that ? Cause I want my original screen to remain.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Reporting Architecture Issue

Post by Jan »

Hello,

At first you need add to your project new aspx page. This page will be used for showing report. After then type following code to redirect to page wich will be used to show report:

Code: Select all

report.Render();
string str = report.SaveDocumentToString();
string guid = Guid.NewGuid().ToString().Replace("-", "");

this.Page.Cache.Add(guid, str, null, Cache.NoAbsoluteExpiration, time, System.Web.Caching.CacheItemPriority.Low, null);

Response.Redirect(string.Format("WebForm2.aspx?report={0}", guid));
In PageLoad event of WebForm2 you need use following code:

Code: Select all

string guid = HttpContext.Current.Request.Params[“report”] as string;
if (guid == null)return;
string str = this.Page.Cache[guid] as string;
if (str == null)return;
StiReport report = new StiReport();
report.LoadDocumentFromString(str);
Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report);

Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Reporting Architecture Issue

Post by fkmfkm »

Hi,

It still prompts me the window to save the pdf...I wants it to open immediately in the acrobat reader while my aspx entry page still remain.

Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Reporting Architecture Issue

Post by Jan »

Hello,

Please replace line of code:

Code: Select all

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report);
to:

Code: Select all

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report, false);
Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Reporting Architecture Issue

Post by fkmfkm »

Jan wrote:Hello,

Please replace line of code:

Code: Select all

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report);
to:

Code: Select all

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report, false);
Thank you.
The problem is my original entry screen is gone...this way...what I left is the acrobat reader screen.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Reporting Architecture Issue

Post by Jan »

Hello,

Sorry in some cases Acrobat Reader can't be opened in full page mode in browser.

Thank you.
Post Reply