Exception while embedding fonts in parallel PDF Export (Plus MemoryLeak)

I have a large number of reports to export to PDFs (3 different reports to an internal ID. I have to run batches of 400+ internal IDs at a time). To speed things up, I tried to run the PDF export in parallel.

If I try to embedd fonts, I keep getting this error:

 at FastReport.Fonts.TrueTypeFont.BuildGlyphIndexList(UInt16[] used_glyphs, Boolean decompose, Boolean collate, Boolean use_kerning, ArrayList& Indices, ArrayList& GlyphWidths)
  at FastReport.Fonts.TrueTypeFont.ReorderGlyphTable(IntPtr position, IList`1 keep_list, Boolean uniscribe, Byte[]& SavedGlyphs, Int16[]& ShortI2L, Int32[]& LongI2L)
  at FastReport.Fonts.TrueTypeFont.PackFont(IList`1 keep_list, Boolean uniscribe)
  at FastReport.Export.TTF.ExportTTFFont.GetFontData(Boolean subsetting)
  at FastReport.Export.Pdf.PDFExport.WriteFont(ExportTTFFont pdfFont)
  at FastReport.Export.Pdf.PDFExport.AddPDFFooter()
  at FastReport.Export.Pdf.PDFExport.Finish()
  at FastReport.Export.ExportBase.Export(Report report, Stream stream)
  at FastReport.Export.ExportBase.Export(Report report, String fileName)
  at FastReport.Report.Export(ExportBase export, String fileName)
  at  cReporting.ExportReportToPdfForParallel(String _sReport, String sFont, String sExportFilePath, Int32 iColorSpace, DataSet dsReportDaten)


The calling function:

 public void ExportReportToPdfForParallel(string _sReport, string sFont, string sExportFilePath, int iColorSpace, DataSet dsReportDaten)
    {
      using (EnvironmentSettings oEnvironmentSettings = new EnvironmentSettings())
      {
        Report oCurrentReport = new Report();
         

          oCurrentReport.LoadFromString(_sReport);

          oEnvironmentSettings.ReportSettings.ShowProgress = false;
          oEnvironmentSettings.ReportSettings.ShowPerformance = false;
   
          using (PDFExport oPdfExport = new PDFExport())
          {
            oPdfExport.HideWindowUI = true;
            oPdfExport.PdfCompliance = PDFExport.PdfStandard.PdfA_2a;
            oPdfExport.EmbeddingFonts = true;


            oPdfExport.Restrictions = Restrictions.DontEdit;
            oPdfExport.AllowModify = false;
            oPdfExport.ColorSpace = (PDFExport.PdfColorSpace)iColorSpace;
    
            if (dsReportDaten != null)
              oCurrentReport.RegisterData(dsReportDaten);

            oCurrentReport.Prepare();

            oCurrentReport.Export(oPdfExport, sExportFilePath);
            oCurrentReport.Delete();
            oCurrentReport.GraphicCache?.Dispose();
             
            dsReportDaten = null;
          }
        oCurrentReport.Dispose();
         
      }
           
    }


On some machines, I'm also getting OutOfMemory Exceptions due to a memory leak somewhere during the

Export. Memory is not released until I close the programm.

It works fine on other machines and I cannot find a common factor.


These errors occur with any of the recent releases (19.4 to the most current of 20.1)


Can anybody help?

Comments

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.