How can I add two messageTop when exporting PDF or Excel File? And How to Make it align in center.

How can I add two messageTop when exporting PDF or Excel File? And How to Make it align in center.

logellologello Posts: 2Questions: 1Answers: 0
edited May 2021 in DataTables

I tried to put header in my file like logo and name and description bellow and I failed. Can anyone help me how to add two messageTop? it only prints the second message, and also can you help me how to make messageTop align in center?

This is my code bellow.

Thank you for helping me.

                    extend: 'pdfHtml5',
                    messageTop: function () {
                            return 'This is the first message.';
                    },
                    messageTop: function () {
                            return 'This is the second message';
                    },
                    title: '',
                    customize: function ( doc ) {
                        doc.pageMargins = [10,80,10,20];
                        doc.defaultStyle.fontSize = 10;
                        doc.styles.tableHeader.fontSize = 12;
                        doc.styles.title.fontSize = 10;
                        // Remove spaces around page title
                        doc.content[0].text = doc.content[0].text.trim();
                        // Create a header
                        doc['header']=(function(page, pages) {
                            return {
                                alignment: 'center',
                                image: 'image: 'data:image/png;base64.....',
                                width: 50,
                                height: 50,
                                margin: [0, 20]
                            }
                        });
                    }
                },

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Yep, you can only have one messageTop, so you would need to put both messages into the single function. For alignment, this thread should help.

    Colin

  • logellologello Posts: 2Questions: 1Answers: 0

    @colin
    Do you have any link for single function for two or more messageTop?

This discussion has been closed.