Bug in image export? CutEdges does not fully cut the margins

Stimulsoft Reports.NET discussion
Post Reply
Tobias
Posts: 102
Joined: Mon Nov 24, 2008 8:44 am

Bug in image export? CutEdges does not fully cut the margins

Post by Tobias »

I've created a report with a width of 58mm and a margin (left/right/top/bottom) of 5. This results in a 48mm wide printable area (this is for a thermal receipt printer).
When I do :

report.ExporDocument(StiExportFormat.ImageBmp, memoryStream,
new StiBmpExportSettings
{
ImageResolution = 203,
PageRange = new StiPagesRange(1),
CutEdges = job.TrimMargins
}

then the resulting image is 399 pixels wide and shows a small margin of 5 pixels. I would expect no margin at all, because of the CutEdges option. So the resulting image should be 203 dpi * 0,0393701 inch/mm * 48 mm = 384 pixels wide.

So it seems CutEdiges did cut the 5 mm margine, except for 5 pixels.

Is this a bug or am I missing a setting somewhere?

If I remove the page margin and set CutEdges = false, then I end up with exactly 384 pixels.
Lech Kulikowski
Posts: 6263
Joined: Tue Mar 20, 2018 5:34 am

Re: Bug in image export? CutEdges does not fully cut the margins

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.
Tobias
Posts: 102
Joined: Mon Nov 24, 2008 8:44 am

Re: Bug in image export? CutEdges does not fully cut the margins

Post by Tobias »

OK. This is really easy to reproduce.

See report1.mrt. It contains a page in size 4 x 4 inch with no margins at all. The page contains a black panel of the same size. Go to Preview and save as PNG with 100 dpi. The resulting image is exactly 400 x 400 pixels, so this is ok (report1.png).

Now the problematic case - See report2.mrt. This time, the page size is 5 x 5 inches but the page has 0.5 inch wide margins. So the resulting usable area is still 4x4 inch. If you render this and export the image with 100 dpi again and enable "CutEdges", then the resulting image is 419 x 419 instead of the expected 400 x 400. The image contains a small margin. It is expected, that with "CutEdges" the margins get cut away, so that I would end up with the same image size as in report1.mrt without any margins defined.
Attachments
Report2.png
Report2.png (4.15 KiB) Viewed 1765 times
Report2.mrt
(2.98 KiB) Downloaded 118 times
Report1.png
Report1.png (1.45 KiB) Viewed 1765 times
Report1.mrt
(2.98 KiB) Downloaded 120 times
Tobias
Posts: 102
Joined: Mon Nov 24, 2008 8:44 am

Re: Bug in image export? CutEdges does not fully cut the margins

Post by Tobias »

Looking at the Reports.Net source code, I see, that with CutEdges set, there are explicitly set a left and right margin to the exported image which is 0.2 times of the orgininal left/right margin. It doesn't make any sense to me, but I see, that this always has been this way, at least since 2010.
Is this a bug or a weird feature?

My workaround for now is, to delete the margins myself before rendering the report and exporting the image:

Code: Select all

if (trimMargins)
{
    foreach (StiPage page in report.Pages)
    {
        page.PageWidth = page.PageWidth - page.Margins.Left - page.Margins.Right;
        page.PageHeight = page.PageHeight - page.Margins.Top - page.Margins.Bottom;
        page.Margins.Left = 0;
        page.Margins.Right = 0;
        page.Margins.Top = 0;
        page.Margins.Bottom = 0;
    }
}

Lech Kulikowski
Posts: 6263
Joined: Tue Mar 20, 2018 5:34 am

Re: Bug in image export? CutEdges does not fully cut the margins

Post by Lech Kulikowski »

Hello,

Please send us your request with a detailed description on support@stimulsoft.com. We will check it and will reply to you by email as fast as possible.

Thank you.
Post Reply