Export to PDF

Export to PDF

ZorroZorro Posts: 3Questions: 1Answers: 0

Hi all,
i'd like to export my table to PDF (and also Excel) using DataTables's algorithm, because i think is so powerful and well made.
But i don't want to use entire engine of this library.
I just want to create my personal button, who export Tables to PDF. Not anymore. No filter, no pagination, nothing.
Don't want to turn off every options, becase is not the same.
Is it possible?
Thanks a lot.

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    You can use rows().data() to get the table's data then provide that to the code you want to use for the PDF button.

    Kevin

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    You want to use our export to PDF, but not DataTables? We use pdfmake to create the PDF, so you would start by using that as well.

    This is the code we use to create a PDF from a DataTable using that library. It heavily uses the DataTables API, so you'd need to rewrite that, if you didn't want to use DataTables, to just get the data from the plain HTML table.

    Allan

  • ZorroZorro Posts: 3Questions: 1Answers: 0

    @kthorngren, could you provide me an example?
    A just added to my project DataTables's library, and then i made a button with a jquery's click event.
    Inside thet event what i have to write?
    Thanks.

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    Hers is an example:
    http://live.datatables.net/waliviqi/1/edit

    It uses the toArray() API to extract the data from the returned API.

    Kevin

  • ZorroZorro Posts: 3Questions: 1Answers: 0

    In that example i don't see the code to export to pdf the table.
    And "change" the table with DataTables's engine.

    I'd like apply no changes to my table, but with a button to export that table to PDF.

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    I don't understand what you mean by apply no changes to the table.

    The example is meant to show how to get the table's data. You will need to use a Javascript library to export the data to PDF. Either use the Datatables provided Buttons extension, see the Buttons extension example. Or find a third party PDF library more suited to what you want.

    Kevin

Sign In or Register to comment.