Parameter is not valid error when calling Export method of PdfExport

Posted by: jaypeemayo on 24 January 2019, 9:27 am EST

  • Posted 24 January 2019, 9:27 am EST

    Error

    - Error Description: Parameter is not valid.
    - Error Type: System.ArgumentException
    - Source: System.Drawing
    - Stack Trace:
    - at System.Drawing.Graphics.GetHdc()
    - at #mqc.#zqc.#Q3m(Font f, #v3m& w)
    - at #mqc.#zqc.#Cud(Font font)
    - at #mqc.#zqc.#Fk(Font font)
    - at #mqc.#zqc..ctor(Font font)
    - at #lSr.#SOn.#tMn()
    - at #lSr.#iRn.#tMn()
    - at DataDynamics.DDLib.PdfEngine.PdfFonts.#U.#Yqc.#WxZ(String fontName, FontStyle fontStyle, Boolean isVertical)
    - at DataDynamics.DDLib.PdfEngine.PdfFonts.#U.#Yqc.#RZc(String fontName, FontStyle fontStyle, Boolean isVertical)
    - at DataDynamics.DDLib.PdfEngine.PdfFonts.#RZc(Int32 fontIndex, String fontName, FontStyle fontStyle, Single sizeInPoints, Boolean vertical)
    - at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.#7pk(SectionDocument document, Stream stream, String pageRange, Byte[]& xmpMetadata)
    - at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(SectionDocument document, Stream stream, String pageRange)
    - at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(SectionDocument document, Stream stream)
    - at StarNet.Core.Reports.ReportExporter.ExportToPdf(ReportBase report, Stream output, String& message)
    - Target Site: IntPtr GetHdc()
    - in System.Drawing.Graphics, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a




    using (PdfExport pdf = new PdfExport())
    {
    pdf.ImageQuality = ImageQuality.Highest;
    pdf.Export(m_reportBase.Document, output);
    result = true;
    }


    We are using
    GrapeCity.ActiveReports.Web.v10

    Any workaround or fix for this?
  • Marked as Answer

    Replied 24 January 2019, 7:57 pm EST

    Hello,

    Thanks for sharing the details.
    As your issue is being addressed on the SupportOne ticket 363495, kindly continue the thread there to avoid confusion.

    Regards,
    Esha
  • Replied 22 April 2019, 8:14 am EST

    Hello, it appears that I am experiencing a similar issue with my application, using my newly-upgraded ActiveReports Standard v13.

    In my case I am exporting a SectionReport to a PDF using the following code:

     PdfExport pdfe = new PdfExport();

    try
    {
    ar.Document.Printer.PrinterName = "";
    ar.DataSource = DataSource;
    ar.DataMember = DataMember;

    ar.Run();

    pdfe.Export(ar.Document, memstream);

    }
    catch (Exception e)
    {
    throw e;
    }


    This does work on most of my multiple reports without any issue, but there are a few for which I receive an exception (below) I was hoping to find out what the issue was in this thread and/or if there are any suggestions as to what to look for? Thanks in advance.

    (also note that all of these reports have previously worked with Activereports 7 -- the conversion to AR 13 mostly involved changing what was ActiveReport to be a SectionReport) Thanks!


    System.ArgumentException
    HResult=0x80070057
    Message=Parameter is not valid.
    Source=GrapeCity.ActiveReports.Export.Pdf
    StackTrace:
    at eo.Add(Image img, Int32 imageConversionQuality, Boolean isMask)
    at eo.Add(ep img, Int32 imageConversionQuality)
    at eo.Add(Image sourceImage, Int32 imageConversionQuality, Int32 resourceKey)
    at ey.DrawImage(et render, ResourcedCanvasItem imageItem, RectangleF rectangle)
    at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.RenderCanvasItems(IEnumerator`1 canvasItems, ey pdfPage, PointF offset, Graphics graphics, fm outputContext, IEnumerable`1 bookmarks, IDictionary`2 pagesMap)
    at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.ExportPage(IFilteredPage page, Graphics graphics, fm outputContext, IEnumerable`1 bookmarks, IDictionary`2 pagesMap)
    at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.ExportImpl(SectionDocument document, Stream stream, String pageRange, Boolean withWatermark, Byte[]& xmpMetadata)
    at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(SectionDocument document, Stream stream, String pageRange)
    at GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport.Export(SectionDocument document, Stream stream)
    at PPReports.PDFHandler.FillPDFStream(MemoryStream memstream, Object DataSource, SectionReport ar, String DataMember) in C:\Users\blair\source\repos\PP\ProfitProfiler\PPReports\PDFHandler.cs:line 27

  • Replied 22 April 2019, 7:28 pm EST

    Hello,

    It is possible that your report contains charts that might cause some issue.
    The reason of this exception was unclear by looking at the stack trace.
    Could you please share that report which you are trying to export? In case you wish to share it privately, you can create a case on SupportOne (https://supportone.componentone.com) and share the same.

    Best Regards,
    Esha
  • Replied 23 April 2019, 2:08 am EST

    Thanks for your response.... I believe I have the issue resolved (or at least identified) My resolution (for reference) was as follows:

    While my report did NOT contain a chart, it DID contain images -- I deleted the images completely and the report was able to export fine.

    I have since tried to identify exactly what is wrong with the images -- it seems that in the reports that DO work, the images are contained as resources within the .resx file of the report itself. I reviewed the originals, and it appears as if the conversion process somehow resulted in the .resx file entries for the images being removed for the failing reports. The generated code still held entries for the images, BUT the images were always null when the InitializeComponent() function was called.

    Luckily, the images are the same across the working and non-working reports, so I was able to use the images from the working reports to rebuild the failing ones.

    Thanks for your assistance.

    Kind regards,
    Blair
  • Replied 23 April 2019, 8:25 pm EST

    Hello Blair,

    Thanks for informing that the issue is resolved for you.
    I tried the scenario at my end using the latest builds but the issue could not be observed.
    There was an issue in the earlier versions of AR 13 wherein there was an issue loading images in a report. However, it was fixed with the hotfix builds: http://cdn.grapecity.com/ActiveReports/AR13/hotfixes/ActiveReports-v13.0.16604.0%20%281%29.msi .
    You can try your application with these builds.
    If the issue persists, share the stripped down sample so that I can investigate on the same and assist you further.

    Regards.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels