Problems with PDF-Export since version 2018.1.6

Stimulsoft Ultimate discussion
Post Reply
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Problems with PDF-Export since version 2018.1.6

Post by tpontow »

Hello Stimulsoft-Team,

recently we switched from Stimulsoft version 2016.3.0.0 to version 2018.1.6.0. Since then we have some problems with PDF exporting Reports. We are using StiReport.ExportDocument() method.

We have nor changed our code for Export neither have we changed the Reports. We use the following method call:

Code: Select all

listReport.ExportDocument(StiExportFormat.Pdf, fileName, new StiPdfExportSettings {ImageQuality = 100.0f, ImageResolution = 300.0f,  })
One Report is stretched over more than one page. With this Report we got an error from the StiSegmentPagesDivider.

Code: Select all

<InnerException ExceptionType="System.NullReferenceException">
      <Number>0</Number>
      <Message>Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.</Message>
      <Source>Stimulsoft.Report</Source>
      <TargetSite>Stimulsoft.Report.Components.StiPagesCollection Divide(Stimulsoft.Report.Components.StiPagesCollection, Stimulsoft.Report.Export.StiExportService)</TargetSite>
      <Class>Stimulsoft.Report.Export.StiSegmentPagesDivider</Class>
      <Assembly>Stimulsoft.Report, Version=2018.1.6.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a</Assembly>
      <Method>Divide</Method>
      <StackTrace>
        <StackTraceElements Count="1">
          <StackTraceElement Number="1">   bei Stimulsoft.Report.Export.StiSegmentPagesDivider.Divide(StiPagesCollection pages, StiExportService service)

 bei Stimulsoft.Report.Export.StiPdfExportService.ExportPdf1(StiReport report, Stream stream, StiPdfExportSettings settings)
 bei Stimulsoft.Report.Export.StiPdfExportService.ExportPdf(StiReport report, Stream stream, StiPdfExportSettings settings)
 bei Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, StiExportService exportService, Stream stream, StiExportSettings settings)
 bei Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, String file, StiExportSettings settings)


Are there any known problems with PDF Export? Can you provide any help? Otherwise we have to go back to version 2016.3.0.0.

Thanks and Kind regards
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Problems with PDF-Export since version 2018.1.6

Post by Edward »

Hi Thorsten,

We are not aware of this issue, do you mind to send a sample report template to support[at]stimulsoft.com for analysis, so we could reproduce the bug?

Thank you,
Edward
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Problems with PDF-Export since version 2018.1.6

Post by tpontow »

----------------------------
[Customer Explanation]

After rendering the Report in my C# code i opened the report in code with viewer (Report.Show(true)) and exported it to PDF using the viewer menu. I got that message (see below). When saving the Report to mdc-File and open that file with the Viewer and Export it to a PDF-file no error occurs.

----------------------------
[General Info]

Application: Exe
Framework: v4.0.30319
Version: Version: 2018.1.6 from 20 January 2018
MachineName: W10-TPONTOW
OSVersion: Microsoft Windows NT 10.0.16299.0
UserName: tpontow

----------------------------
[Exception Info]
Message: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

Source: Stimulsoft.Report

StackTrace:
bei Stimulsoft.Report.Export.StiSegmentPagesDivider.Divide(StiPagesCollection pages, StiExportService service)
bei Stimulsoft.Report.Export.StiPdfExportService.ExportPdf1(StiReport report, Stream stream, StiPdfExportSettings settings)
bei Stimulsoft.Report.Export.StiPdfExportService.ExportPdf(StiReport report, Stream stream, StiPdfExportSettings settings)
bei Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, StiExportService exportService, Stream stream, StiExportSettings settings)
bei Stimulsoft.Report.Export.StiExportService.DoExport(StiExportInfo info)
bei Stimulsoft.Report.Export.StiExportService.StartExport(StiReport report, Stream stream, StiExportSettings settings, Boolean sendEMail, Boolean openAfterExport, String fileName, StiGuiMode guiMode)
bei Stimulsoft.Report.Export.StiPdfExportService.form_Complete(IStiFormRunner form, StiShowDialogCompleteEvetArgs e)
bei Stimulsoft.Base.StiWinFormRunner.InvokeComplete(Boolean dialogResult)
bei Stimulsoft.Base.StiWinFormRunner.ShowDialog()
bei Stimulsoft.Report.Export.StiPdfExportService.Export(StiReport report, String fileName, Boolean sendEMail, StiGuiMode guiMode)
bei Stimulsoft.Report.Export.StiExportService.Export(StiReport report, String file, Boolean sendEMail)
bei Stimulsoft.Report.Viewer.StiViewerControl.OnProcessExport(Object sender)
bei Stimulsoft.Report.Viewer.StiViewerControl.InvokeProcessExport(StiExportService service)
bei Stimulsoft.Report.Viewer.StiViewerControl.cmExport_Click(Object sender, EventArgs e)

----------------------------
[Assemblies]
mscorlib, Version = 4.0.0.0
Stotax.Framework.Presentation, Version = 1.0.0.0
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Problems with PDF-Export since version 2018.1.6

Post by tpontow »

If you load the attached mdc-file into a report in Code and then call

Code: Select all

StiReport rep = new StiReport();
rep.LoadDocument("ReportAsPDF.mdc");
rep.ExportDocument(StiExportFormat.Pdf, @".\ReportAsPDF.pdf", new StiPdfExportSettings { ImageQuality = 100.0f, ImageResolution = 300.0f, });
the error occurs.
Attachments
ReportAsPDF.mdc
Rendered Report save as document
(185.71 KiB) Downloaded 228 times
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Problems with PDF-Export since version 2018.1.6

Post by tpontow »

I debugged in Stimulsoft source and found the Problem in

Code: Select all

StiSegmentPagesDivider: public static StiPagesCollection Divide(StiPagesCollection pages, StiExportService service)
Problem is line 137, soft cast to StiImage but then Access to property Border without null check.

Code: Select all

var needClip = !(service is StiPdfExportService);

#region Make new component
StiComponent newComp = null;
if (comp is StiContainer)
    newComp = comp.Clone() as StiContainer;

if (comp is StiText)
{
    var txtComp = comp.Clone() as StiText;
    if (needClip)
        txtComp.Text = string.Empty;

    newComp = txtComp;
}

//NULLREFERENCEEXCEPTION if comp is NO StiImage!!!
var cont = new StiContainer
{
    Border = (comp as StiImage).Border,
    Brush = (comp as StiImage).Brush
};
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Problems with PDF-Export since version 2018.1.6

Post by tpontow »

This is older code from version 2016.3 that we used before. Everything was ok then. I think there are significant changes made since then :o

Code: Select all

foreach (StiComponent comp in page.Components)
{
    if (comp.Enabled)
    {
        //if (rect.Contains(comp.Left, comp.Top))
        if ((rectX <= (decimal)comp.Left) && ((decimal)comp.Left < rectR) && (rectY <= (decimal)comp.Top) && ((decimal)comp.Top < rectH))
        {
            if (rect.Left == 0 && rect.Top == 0)
            {
                newPage.Components.Add(comp);
            }
            else
            {
                StiComponent newComp = comp.Clone() as StiComponent;
                newComp.Left -= rect.Left;
                newComp.Top -= rect.Top;
                newPage.Components.Add(newComp);
            }
        }
    }
}

newPages.Add(newPage);
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Problems with PDF-Export since version 2018.1.6

Post by tpontow »

Hello Edward,

i saw that error is corrected in code of StiSegmentPagesDivider in latest Version 2018.1.8. I will install that version and will come back later.

Thanks
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Problems with PDF-Export since version 2018.1.6

Post by Alex K. »

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply