Hi everybody,
I've just created a .trdx report containing a subreport using Telerik Report Designer. I would like to export a pdf file based on this report so I've created a web page having this method server side:
void
ExportToPDF()
{
var reportProcessor =
new
Telerik.Reporting.Processing.ReportProcessor();
var deviceInfo =
new
System.Collections.Hashtable();
UriReportSource NetCatalogPDF =
new
UriReportSource();
NetCatalogPDF.Uri = Server.MapPath(
"~/Report/Standard/CatalogPDF.trdx"
);
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"CompanyCode"
, CompanyCode));
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"LanguageCode"
, PageLanguage));
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"FamilyId"
, (ddlFamily.SelectedValue !=
"-1"
) ? ddlFamily.SelectedValue :
null
));
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"IncludePrices"
, chkIncludePrices.Checked));
if
(chkIncludePrices.Checked)
{
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"PriceListCode"
, ddlPriceList.SelectedValue));
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"CustomerCode"
, txtCustomerCode.Text));
}
else
{
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"PriceListCode"
,
null
));
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"CustomerCode"
,
null
));
}
NetCatalogPDF.Parameters.Add(
new
Telerik.Reporting.Parameter(
"ImagesPath"
, Server.MapPath(
"/Catalog/public/images/catalog/products/zoom"
)));
var connectionStringHandler =
new
ReportConnectionStringManager(ConnectionString);
try
{
var reportSource = connectionStringHandler.UpdateReportSource(NetCatalogPDF);
var result = reportProcessor.RenderReport(
"PDF"
, reportSource, deviceInfo);
this
.Response.Clear();
this
.Response.ContentType = result.MimeType;
this
.Response.Cache.SetCacheability(HttpCacheability.Private);
this
.Response.Expires = -1;
this
.Response.Buffer =
true
;
// Uncomment to handle the file as attachment
//Response.AddHeader("Content-Disposition",
// string.Format("{0};FileName=\"{1}\"",
// "attachment",
// "Report.pdf"));
this
.Response.BinaryWrite(result.DocumentBytes);
this
.Response.End();
}
catch
(Exception ex)
{
ErrMess = ex.Message;
}
}
Anyway the line
var result = reportProcessor.RenderReport(
"PDF"
, reportSource, deviceInfo);
throw an exception:
Cannot find the file 'c:\windows\system32\inetsrv\CatalogPDF_Sub.trdx'. "CatalogPDF_Sub.trdx" is subreport file name. Obviously the path is wrong because that file is located in the same main report folder ("~/Report/Standard/").
How can I solve this problem?
Thank you in advance for your replies.