Problems with exporting to pdf

Posted by: info on 11 July 2022, 12:07 am EST

  • Posted 11 July 2022, 12:07 am EST

    Hello,

    i am using the flexreport in an asp.net core mvc application.

    Everything works fine if I render and print the report in A4.

    If, on the other hand, I export it to PDF, the page size changes making the document not conform to A4 format.

    The code is very simple.

    I am attaching both the report and the generated PDF file and the code.

    Can someone help me?

    Thanks, regards,

    Marco

  • Posted 11 July 2022, 12:11 am EST

  • Posted 11 July 2022, 12:11 am EST

    Pdf Exported

  • Posted 12 July 2022, 6:08 pm EST

    Hi, here the code.

    In the report the a4 format is set, in the PDF the dimension is set to 280x396mm.

    Any suggest?

    Regards

    
                C1FlexReport report = new();
                report.Load(filePathName, reportName);
                foreach (DataSource dataSource in report.DataSources)
                {
                    dataSource.DataProvider = DataProvider.OLEDB;
                    dataSource.RecordSource = recordSource ?? string.Empty;
                    dataSource.RecordSourceType = recordSourceType ?? RecordSourceType.Auto;
                }
    
                SetupConnectionString(report, oleDbConnectionString);
    
                await report.GenerateAsync();
                await report.RenderAsync();
    
                PdfFilter filter = new()
                {
                    Stream = new MemoryStream(),
                    DocumentInfo = new DocumentInfo
                    {
                        Author = "MANDO",
                        CreationTime = DateTime.Now,
                        RevisionTime = DateTime.Now,
                        Creator = "MANDO",
                        Title = toPdfFileName
                    },
                    PageSettings = new C1PageSettings
                    {
                        Landscape = false,
                        PaperSize = PaperKind.A4
                    },
                    FileName = toPdfFileName,
                    PdfACompatible = true,
                    Preview = true
                };
                await report.RenderToFilterAsync(filter);
                return ((MemoryStream)filter.Stream).ToArray();
    
    
  • Posted 13 July 2022, 4:04 am EST

    Hi,

    We are investigating on this and update as we have an update on this.

    Manish Gupta

  • Posted 14 July 2022, 10:00 pm EST

    Hi,

    We are sorry for the inconvenience but we are unable to replicate the PDF on our end. Please refer to the attached sample for reference.

    Regards,

    Manish Gupta

    FlexReport_ExportPDF___.zip

  • Posted 18 July 2022, 2:44 am EST

    Hi,

    i checked the example and it works bug it was made in .Net Framework 4.8 while we are developing it on .NET CORE 6.0.

    I think there is a bug in the CORE 6.0 libraries

    Thank you, Regards, Marco Casaburi

  • Posted 18 July 2022, 3:15 am EST

    Here an example with correct references.

    ReportTry.zip

  • Posted 19 July 2022, 1:49 pm EST

    Hi,

    Thank you for reporting the issue. We are able to replicate it with Asp.Net core and it has been forwarded to the concerned team with the internal tracking id C1WEB-29217.

    We will let you know as we get an update on this.

    Regards,

    Manish Gupta

  • Posted 20 July 2022, 6:49 pm EST

    Hi Manish, I hope you treat this report with the highest priority. Badly exporting reports to PDF represents a very high criticality for the application.

    I am waiting for news,

    regards.

    Marco Casaburi

  • Posted 31 January 2023, 4:39 am EST

    hello, any update? regards

  • Posted 1 February 2023, 2:45 am EST

    Hi,

    We have a solution for now and it should work for you. We need to provide the setting for PdfFilter and PageSettings too. This works when Landscape is set to true.

    Please refer to the following code snippet for reference and try at your end.

    PdfFilter filter = new()
                {
                    Stream = new MemoryStream(),
                    DocumentInfo = new DocumentInfo
                    {
                        Author = "MANDO",
                        CreationTime = DateTime.Now,
                        RevisionTime = DateTime.Now,
                        Creator = "MANDO",
                        Title = toPdfFileName
                    },
                    PageSettings = new C1PageSettings
                    {
                        Landscape = true,
                        PaperSize = PaperKind.A4
                    },
                    FileName = toPdfFileName,
                    PdfACompatible = true,
                    Preview = false
                };
                C1PageSettings pageSettings = new C1PageSettings
                {
                    Landscape = true,
                    PaperSize = PaperKind.A4
                };
    
                report.PageSettings = pageSettings;

    Regards,

    Manish Gupta

Need extra support?

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

Learn More

Forum Channels