Date Format for Wijmo pdf Report

Posted by: kapil.r.shah on 23 November 2019, 4:14 pm EST

    • Post Options:
    • Link

    Posted 23 November 2019, 4:14 pm EST

    I am trying to generate a pdf report using PdfDocument API refering the following link

    https://www.grapecity.com/wijmo/demos/PDF/ExpenseReport/angular

    I am using the following line of code to render the date

        doc.drawText('From: ', 380, 0, { font: bold, continued: true });
        doc.drawText(wijmo.changeType(minDate, wijmo.DataType.String, 'd'));
    

    My Date value is : 2019-11-16T15:07:44.7086635-05:00 .

    I want to format it as MM/dd/yyyy

    I change the format to

    doc.drawText('From: ', 380, 0, { font: bold, continued: true });

    doc.drawText(wijmo.changeType(minDate, wijmo.DataType.Date, ‘MM/dd/yyyy’));

    but it give me the value 2019-11-16T15:07:44.7086635-05:00

    How do I format it to ‘MM/dd/yyyy’

    Thanks

  • Posted 25 November 2019, 4:07 am EST

    Hi Kapil,

    The issue seems to be arising because you are providing the type parameter in the changeType method as wijmo.DataType.Date instead of wijmo.DataType.String.

    Also, the ‘d’ format is a short version for ‘MM/dd/yyyy’ format. So, you can easily use ‘d’ to format your date to the desired format. You will also need to convert the string date to a Date object before converting. Please refer to the code snippet below:

    doc.drawText(wijmo.changeType(new Date('2019-11-16T15:07:44.7086635-05:00'), wijmo.DataType.String, 'd'));
    

    Let us know if this solves your issue or otherwise.

    Regards,

    Ashwin

  • Posted 25 November 2019, 4:09 pm EST

    Thanks Ashwin. It works

Need extra support?

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

Learn More

Forum Channels