I am trying to export a specific page from report contains many pages to an image, and it always return the same page which the first on,
I tried to pass the page number in the export settings and it ignored it, below is the code, thanks in advance:
Code: Select all
StiBusinessObject currentBusinessObject = businessObject;
StiReport report = new StiReport();
string units = "";
if (currentBusinessObject != null)
{
report.Dictionary.BusinessObjects.Clear();
report.Dictionary.BusinessObjects.Add(currentBusinessObject);
report.RegBusinessObject(currentBusinessObject.Category, currentBusinessObject.Name, currentBusinessObject.BusinessObjectValue);
}
report.Dictionary.SynchronizeBusinessObjects();
report.Load(documenttypeTemplate.TemplateBody);
report.Render();
string result= report.SaveDocumentToString();
MemoryStream memoryStream = new MemoryStream();
Stimulsoft.Report.Components.StiMargins margins = new Stimulsoft.Report.Components.StiMargins() { Bottom = 0, Right = 0, Left = 0, Top = 0 };
foreach (StiPage page in report.RenderedPages)
{
page.Margins = margins;
}
units = report.ReportUnit.ToString();
string EditableFields = "";
if (documentOut.EditableFields != null)
{
EditableFields = System.Text.Encoding.UTF8.GetString(documentOut.EditableFields);
Stream editableFieldsStream;
using (editableFieldsStream = new MemoryStream())
{
editableFieldsStream.Write(documentOut.EditableFields, 0, documentOut.EditableFields.Length);
editableFieldsStream.Seek(0, SeekOrigin.Begin);
report.LoadEditableFields(editableFieldsStream);
}
}
report.Unit = new StiCentimetersUnit();
report.ReportUnit = StiReportUnitType.Centimeters;
report.ExportDocument(StiExportFormat.ImagePng, memoryStream, new Stimulsoft.Report.Export.StiPngExportSettings() { PageRange = new Stimulsoft.Report.StiPagesRange(StiRangeType.Pages, Pagenumber.ToString(), Pagenumber), MultipleFiles = true, CutEdges = true, ImageResolution = 200, ImageFormat = StiImageFormat.Color });