Searching for a way to generate a pdf of multiple selected rows in vue-tables-2, I came across the pdf library called pdfmake which seems promising. As someone new to this concept, I'm having difficulty figuring out how to:
- Integrate it into a vue-tables-2 component. Should I import it directly into the component?
- Create a pdf containing data from multiple selected table rows. I have access to
this.checkedRows
which contains the tableData content. How do I incorporate this into the pdf?
I noticed that pdfmake provides instructions on constructing datatable content, but I'm unsure how to apply this to vue-tables-2. Take a look at this pdfmake table content screenshot
If you are aware of a better pdf library option for use with vue-tables-2, please share your suggestions. Here's the code snippet I currently have...
<v-server-table url="/removals" :data="tableData" :columns="columns" :options="options">
<input slot="selected" slot-scope="props" type="checkbox" :checked="props.row.selected" v-model="checkedRows" :value="props.row">
<button slot="afterFilter" type="submit" @click="createPDF">Create PDF</button>
</v-server-table>
The structure of my data is quite basic at the moment:
data() {
return {
tableData: [],
checkedRows: [],
columns: [
'selected',
'sku',
],
options: {
}
}
And the method I'm using...
methods: {
createPDF() {
pdfMake.createPdf(docDefinition).download('PO.pdf');
}
}