Can i add the custom message in the same row as the title in pdfhtml5 export

Can i add the custom message in the same row as the title in pdfhtml5 export

gabrielandregabrielandre Posts: 4Questions: 1Answers: 1
edited February 2017 in Free community support

I have the title left aligned, now i want to add the message on the same row but right aligned:

extend: "pdfHtml5", className: "btn-sm", orientation: 'portrait', pageSize: 'LETTER', title: '@Localizer["MERCHANT REPORT"]', exportOptions: {
columns: [0, 1, 2, 3, 4]
},
message: 'Dashboard ',
customize: function (doc) {

                     doc.content[2].table.widths = ['40%', '15%', '20%', '15%', '10%'];

                     doc.defaultStyle.fontSize = 8;

                     doc['footer'] = (function (page, pages) {
                         return {
                             columns: [
                             '@Localizer["REPORT DATE:"]' + ' ' + moment().format('YYYY-MM-DD, HH:mm:ss') + '',
                             {
                                 alignment: 'right',
                                 text: [
                                 { text: page.toString(), italics: true },
                                 ' of ',
                                 { text: pages.toString(), italics: true }
                                 ]
                             }],
                             margin: [10, 0]
                         }
                     });
                 }
             },

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,771Questions: 1Answers: 10,112 Site admin

    You've certainly got the right idea of using the customize method - but exactly how you do the layout aspect with the pdfmake API, I'm afraid you'd need to refer to the pdfmake documentation and support channels.

    Allan

  • gabrielandregabrielandre Posts: 4Questions: 1Answers: 1
    Answer ✓

    Thanks for the advice, i managed to fix the alignment playing with the margins in the buttons.html5.js

    g.message && c.content.unshift({
    text: g.message,
    style: "message",
    margin: [0, 0, 0, 25]//margin adjusted to align with title

            }), g.title && c.content.unshift({
                text: t(g, !1),
                style: "title",
                margin: [0, 0, 0, -25]//aligned to message
            }), g.customize && g.customize(c), c = b.pdfMake.createPdf(c), "open" !== g.download || w() ? c.getBuffer(function (a) {
                a = new Blob([a], {
                    type: "application/pdf"
                }), e(a, s(g))
            }) : c.open()
    
This discussion has been closed.