Export SectionReport to Bitmap

Posted by: ralkassab on 27 June 2022, 6:53 am EST

  • Posted 27 June 2022, 6:53 am EST

    Hi,

    I am having an issue trying to export a SectionReport with a single barcode control to an image.

    What I do is straight forward.
     
    private void DrawBarcode(Page page, out Bitmap bmp)
    {
    var width = (int)Math.Ceiling(_reportPaperWidth * DPI);
    var height = (int)Math.Ceiling(_reportPaperHeight * DPI);

    bmp = new Bitmap(width, height);
    Graphics g = Graphics.FromImage(bmp);

    g.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
    page.Draw(g, new RectangleF(0, 0, page.Width, page.Height));
    }


    The problem with this is the page dpi cannot be changed and it is always set to native dpi of 96. so the more I increase my bitmap dpi the smaller the content will be in the bitmap.

    I tried to create pagereport and add the barcode control to it but I was not able to add SectionReport barcode to page report even when casting it as CustomReportItem.

    How can I achieve high resolution image rendering if page resolution is set in stone?

    thanks
  • Marked as Answer

    Replied 28 June 2022, 3:55 pm EST

    Hello,

    The native resolution of the windows desktop is typically 96dpi, so in the viewer/designer the rendered report is displayed with the same DPI. However, if you print, export or zoom in the images you will see the difference in quality of the image rendered when compared to another image the same size but lower DPI.

    Thanks,
    Akshay
Need extra support?

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

Learn More

Forum Channels