SVG is not sized to the correct size

Posted by: roman.mueller on 9 September 2024, 8:19 am EST

    • Post Options:
    • Link

    Posted 9 September 2024, 8:19 am EST

    I have an SVG image as a byte, which has “width” of 21cm and “height” of 11cm.

    On a report I have a Picture control pic. When I set the ImageBytes property to the SVG byte, the size of the picture control is not used, although the picture control and the SVG have the same height/width.

    
    byte[] svgBa = data;
    pic.ImageBytes = svgBa;


    However, the picture in ActiveReport does not get the right size. It’s way too small and when I use the SizeMode “Zoom”, the image is displayed in an awful quality.

  • Posted 10 September 2024, 2:35 am EST

    Hi Roman,

    Could you please try using the Stretch SizeMode and let us know if it helps?

    If the issue persists, please share with us the following:

    • You sample, stripped-down and runnable report
    • SVG image causing the issue
    • Video demonstrating the issue/steps to reproduce the issue

    Attachment: SvgImage.zip

  • Posted 11 September 2024, 10:01 am EST - Updated 11 September 2024, 10:15 am EST

    I created an Example.zip.

    There it looks quite good on my environment.

    PdfExporter exporter new PdfExporter();
    exporter.Export(billReport.Document, @"C:\Temp\BillReport.pdf");


    In my scenario I need to add that bill report as a page to a full report. Therefore, I added an example using

    SectionDocument sd = new SectionDocument();
    sd.Pages.Add(billReport.Document.Pages[0]);
    exporter.Export(sd, @"C:\Temp\FullDocument.pdf");

    That looks good in the example but in my production code with the exact same code, the PDF looks completely pixeled.

    What’s wrong?

  • Posted 12 September 2024, 4:54 am EST

    Hi Roman,

    Could you please confirm that you have set the Compatibility Mode of the Section Report to Cross-Platform in your application that has been deployed? If not, you can do so using the following code:

    sectionReport.CompatibilityMode = GrapeCity.ActiveReports.Document.CompatibilityModes.CrossPlatform;

    If the issue still persists, please share with us your production environment details so that we could try deploying your shared sample there and investigate further.

  • Posted 17 September 2024, 9:58 am EST

    I set the CompatibilityMode to CrossPlatform. Now, the report looks ok and also the print via the AR print method looks good. However, when I print it with a print job to different printer trays, the output is pixeled.

    SystemPrinter printer = new SystemPrinter();
    printer.PrinterName = printerName;
    printer.Copies = Convert.ToInt16(copies);
    try
    {
        printer.PrinterSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
        printer.StartJob(string.Format(CultureInfo.InvariantCulture, @"{0} {1}", LocalizedStrings.Planura, reportName));
        for (int i = 0; i < doc.Pages.Count; i++)
        {
            if (i < pageFrom - 1 || i > pageTo - 1)
            {
                continue;
            }
    
            float x = 0 - (printer.PrinterSettings.DefaultPageSettings.HardMarginX / 100);
            float y = 0 - (printer.PrinterSettings.DefaultPageSettings.HardMarginY / 100);
            System.Drawing.RectangleF rcPage = new System.Drawing.RectangleF(x, y, doc.Pages[i].Width, doc.Pages[i].Height);
            printer.PaperSource = this.GetPaperSourceForPage(printer.PrinterSettings, i + 1, this.currentPagePrintPageMapping, this.currentPrintConfiguration);
            printer.StartPage();
            doc.Pages[i].Draw(printer.Graphics, rcPage);
            printer.EndPage();
        }
    
        printer.EndJob();
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex);
    }

    Any ideas why?

  • Posted 18 September 2024, 2:42 am EST

    Hi Roman,

    Can you please share with us a minimal sample replicating the issue along with your printer details, printer settings details, and production details, so that we can investigate further?

  • Posted 19 September 2024, 2:09 am EST - Updated 19 September 2024, 2:15 am EST

    I tried to do it in another way according to an ActiveReport sample how to print on different trays. However, when I print the SectionDocument, the PrintProgress event is not raised.

    SectionDocument doc = new SectionDocument();
    //...
    doc.Printer.PrinterName = printerName;
    doc.Printer.PrinterSettings.Copies = copies;
    doc.PrintProgress += this.OnPrintProgress;
    doc.Print(false);
    private void OnPrintProgress(object sender, GrapeCity.ActiveReports.Printing.PrintProgressEventArgs e)
    {
        SectionDocument doc = sender as SectionDocument;
        if (doc != null)
        {
            doc.Printer.DefaultPageSettings.PaperSource = this.GetPaperSourceForPage(doc.Printer.PrinterSettings, e.CurrentPage, this.currentPagePrintPageMapping, this.currentPrintConfiguration);
        }
    }

    Did I forget something?

  • Posted 19 September 2024, 2:37 am EST

    Hi Roman,

    >> However, when I print the SectionDocument, the PrintProgress event is not raised.

    This is a reported issue [AR-34036], and its fix is expected to be rolled out with ActiveReports v18.2 (ETA: mid-October 2024).

    For your initial issue, we would request that you share with us a minimal sample replicating the issue of the output being pixelated when using different printer trays along with your printer details, printer settings details, and production details, so that we can investigate further.

Need extra support?

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

Learn More

Forum Channels