Events working with PDF doesn't fire when doing Export (and questions about pdf customization)

Hi,

1) I'm trying to customize the PDF export of Grid but I'm not so successful as I like to.
I'm able to customize header, footer, columns, that are exported, even the datasource, but no chance to fire the "PdfGroupCaptionTemplate", "PdfHeaderQueryCellInfoEvent" and "PdfAggregateTemplateInfo" - they are not fired at all.
I've tried all the available options which I found in documentation even in demos, but the events are not firing, so I can't customize the pdf as I want to.

2) Also - is there a way how to change the coding, that the export displays correctly our Czech characters? (like 'š', 'ě'...)

3) And one more question - is there a way, how to begin the summary of one day on new line page? (that it doesn't get split on two pages)

Could you, please, help? 
Sample with data and also the pdf and things I want to change in attachment. 
Version of SF Components in our project was 19.0.4, so I upgraded to 20.0.2.36, the behaviour is the same.

Thank you very much

Jakub


Attachment: 20220708GridPdfExport_c637968c.zip

13 Replies

MS Monisha Saravanan Syncfusion Team July 11, 2022 02:03 PM UTC

Hi Jakub,


Greetings from Syncfusion support.


Query: “fire the "PdfGroupCaptionTemplate", "PdfHeaderQueryCellInfoEvent" and  "PdfAggregateTemplateInfo" - they are not fired at all.”


We have checked your query and we could see that you have not used aggregate columns inside the SfGrid. We would like to inform that PdfGroupCaptionTemplate and PdfAggregateTemplateInfo will trigger only when the Grid has aggregate or caption columns. Kindly check the attached code snippet for your reference.


<GridAggregates>

        <GridAggregate>

            <GridAggregateColumns>

                <GridAggregateColumn Field=@nameof(Product.UnitsInStock) Type="AggregateType.Sum">

                    <GroupCaptionTemplate>

                    </GroupCaptionTemplate>

                </GridAggregateColumn>

            

                <GridAggregateColumn Field=@nameof(Order.Freight) Type="AggregateType.Average">

 

                    <GroupFooterTemplate>

 

 

                    </GroupFooterTemplate>

 

                </GridAggregateColumn>

 

 

            </GridAggregateColumns>

        </GridAggregate>

    </GridAggregates>

 


Query: “is there a way how to change the coding, that the export displays correctly our Czech characters? (like 'š', 'ě'...)”.


From your shared pdf we could see that the Czech characters are  rendered properly inside Pdf. Kindly share us whether you are facing difficulties in displaying the Czeh characherts from an template column or an normal Grid column.


Query: “is there a way, how to begin the summary of one day on new line page? (that it doesn't get split on two pages)”


We would like to inform that we don’t have inbuilt support to split the pdf pages in to two pages based on the Grouped records.


Kindly get back to us if you have further queries.


Regards,

Monisha



JP Jakub Prosek July 14, 2022 05:26 AM UTC

Hello, 

thanks for the help,  I couldn't find the information about need of templates to get the actions firing. (I'll test it today)

The czech characters doesn't display correctly and it could be seen in the PDF - there are some letters missing - f.e. 'š' and 'ě' (could be found in the data, which was sent with the code).

Is there any posibility to make the "split of the pdf pages based on grouped records" as a features request? Should I open a new one or could you, please, do it? 

Thanks a lot and have a nice day

Jakub 



SP Sarveswaran Palani Syncfusion Team July 16, 2022 12:29 AM UTC

Hi Jakub ,


Sorry for the Inconvenience.


We are currently Validating the reported query with high priority at our end, and we will update the further details within two business days. Until then we appreciate your patience.


Regards,

Sarveswaran PK



SP Sarveswaran Palani Syncfusion Team July 19, 2022 03:26 PM UTC

Hi Jakub,


Thanks for the Patience.


Query 1: “ Czech characters aren’t display properly while exporting


By default, we have provided support for very few of the fonts to exported to PDF format. So, to export Czech or any other language letters(True type font) to PDF format, we need to set True Type font information as base64 string to FontFamily of PdfGridFont. We have provided support for PdfTrueTypeFont in PdfExport() method.  Using this we can export the different font to pdf format from Grid.


Please apply your corresponding custom TTF as base64 string for the FontFamily. Please use the codes in your application based on your needs, 


public void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args)
        {
            if (args.Item.Id == "Grid_pdfexport")
            {
                PdfExportProperties ExportProperties = new PdfExportProperties();
                PdfTheme Theme = new PdfTheme();
                PdfThemeStyle RecordThemeStyle = new PdfThemeStyle()
                {
                    FontColor = "#64FA50",
                    FontName = "Calibri",
                    FontSize = 17,
                    Font = new PdfGridFont() { IsTrueType = true, FontStyle = "Italic", FontSize = 8, FontFamily = "AAEAAA…. /gAtAdUALQIDYQNrA3IDqgAA" },/*you fonts famiy in form of base64string*/                
                };
            Theme.Record = RecordThemeStyle;
            ExportProperties.Theme = Theme;
            this.Grid.PdfExport(ExportProperties);
        }
        if (args.Item.Id == "Grid_excelexport")
        {
            this.Grid.ExcelExport();
        }
        if (args.Item.Id == "Grid_csvexport")
        {
            this.Grid.CsvExport();
        }
    }

 


Note : We request you to use the corresponding custom font base64 string in your application, based on your requirement. Please follow the below steps to get the base64 string for the custom font.

  1. Download TTF file for the corresponding (custom) font (https://www.fontsquirrel.com/fonts/list/language/czech  )
  2. Then convert the TTF file into base64 string (https://www.giftofspeed.com/base64-encoder/).
  3. Finally apply the base64 string to pdfTrupetypeFont.


Refer our UG documentation for your reference


https://blazor.syncfusion.com/documentation/datagrid/pdf-export/#theme


Query 2: “split of the pdf pages based on grouped records


We have analyzed your query but still we’re quit unclear about your exact requirement. Please mention if you want to render each groups in separate pages or render page exceeding specific group in separate page. Please share the necessary details to further evaluate the query.


Kindly get back to us if you have any further queries


Regards,

Sarveswaran PK



JP Jakub Prosek replied to Monisha Saravanan July 21, 2022 10:21 AM UTC

Hi,

I finnally got the time to test the replies so here's my feedback:

Query: “fire the "PdfGroupCaptionTemplate", "PdfHeaderQueryCellInfoEvent" and  "PdfAggregateTemplateInfo" - they are not fired at all.”

You are writing about "GridAggregates" but I use "GridGroupSettings" - despite those misunderstanding I got to use of CaptionTemplate and changing the values of cell inPdfGroupCaptionTemplateInfo - so it helped, thanks. 


Query 1: “ Czech characters aren’t display properly while exporting

Thank you for help - it's OK now - is there any other option where to get those information instead of writing on forums? I couldn't find it anywhere in documentation or demos.


Query 2: “split of the pdf pages based on grouped records

Its about begining the group data on new page if it doesn't fit the previous one.

F.e.

On one page of PDF export I can get 30 rows of data

I have 3 groups of data - 1st group 15records, 2nd group 10 records, 3rd group 10 records, so the 3rd group automatically starts to export on 2nd page of pdf, because it won't fit the first one.


Thanks a lot for help and have a nice day


Regards, Jakub



SP Sarveswaran Palani Syncfusion Team July 22, 2022 02:07 PM UTC

Hi Jakub,

Thanks for your update.

We are currently Validating the split of the pdf pages based on grouped records with high priority at our end, and we will update the further details within two business days. Until then we appreciate your patience.

Until then we appreciate your patience.

Regards,

Sarveswaran PK




SP Sarveswaran Palani Syncfusion Team July 26, 2022 02:52 PM UTC

Hi Jakub,


Thanks for your patience.


Query: “split of the pdf pages based on grouped records


In our Grid rendering approach, based on the current page size and grid bounds, the rows will be fit on that page and other remaining rows will be added in next page. We cannot able to fit the table more than the size of the page to the page whereas we can able to resize page based on the table size using size overload available in the PageSettings API. Please try this in your end let us know if it satisfies your requirement.


Please try the below code snippet:

//Createnew instance for page settings with predefined page size.

PdfPageSettings setting = new PdfPageSettings(new SizeF(595,1200));


Please follow the below links for more information,

https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.PdfPageSettings.html#Syncfusion_Pdf_PdfPageSettings__ctor_System_Drawing_SizeF_


Note: We also support drawing multiple tables in the pdf page.

https://www.syncfusion.com/kb/11732/how-to-add-multiple-table-sequentially-in-a-pdf-with-pagination-using-c


Please let us know if you need any further assistance in this.


Regards,

Sarveswaran PK



JP Jakub Prosek July 27, 2022 09:36 AM UTC

Hello,

you didn't get the point. 

I don't want to fit the records on one page. I want to fit the next group of records on the second page if it doesn' fit the first one. Please refer to the image below.


groupPDFSplit.png

Thanks a lot

Regards

Jakub



SP Sarveswaran Palani Syncfusion Team July 28, 2022 04:17 PM UTC

Hi Jakub,

Sorry for the Inconvenience.

We are currently Validating the reported query with high priority at our end, and we will update the further details within two business days. Until then we appreciate your patience.

Regards,

Sarveswaran PK



SP Sarveswaran Palani Syncfusion Team July 29, 2022 03:36 PM UTC

Hi Jakub,


Sorry for the delay and inconvenience caused.


We would like to inform you that currently we didn’t have support to paginate the entire group of records if some of the records in a group doesn’t fit in the page.


Please get back to us if you have any further queries


Regards,

Sarveswaran PK



JP Jakub Prosek August 1, 2022 09:16 AM UTC

Hi,


as I wrote on July 14: 

Is there any posibility to make the "split of the pdf pages based on grouped records" as a features request? Should I open a new one or could you, please, do it? 


It would be a really helpfull feature for not only this case.

Thanks a lot


BR, Jakub



IJ Irfana Jaffer Sadhik Syncfusion Team August 2, 2022 02:21 PM UTC

Hi Jakub,


Currently, we are checking the other possibilities for this requirement on our end and we will update the further details by August 4th 2022.


Regards,

Irfana J.



IJ Irfana Jaffer Sadhik Syncfusion Team August 4, 2022 12:15 PM UTC

Hi Jakub,

As we have already said we do not have direct support to paginate the entire group of records if some of the records in a group does not fit in the page. But as a workaround we can able to achieve the scenario by drawing multiple table in the pdf page and to paginate if any of the records in the table doesn’t fit the current page. We have attached the workaround sample with the output document for your reference. Please try this in your end and let us know if it satisfies your requirement.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NetCoreSample-325689329

Document: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Output-1125719995


Please follow the below links for more information,

https://help.syncfusion.com/file-formats/pdf/working-with-tables?cs-save-lang=1&cs-lang=csharp

https://help.syncfusion.com/file-formats/pdf/working-with-tables?cs-save-lang=1&cs-lang=csharp#pagination-in-pdfgrid

If this does not satisfy your requirement, we request you to share the modified code sample. So that will be helpful for us to assist with you further on this.


Please let us know if you any further assistance in this.


Regards,

Irfana J.


Loader.
Up arrow icon