Reputation: 47
private printCoverLetter(){
const selectedRows: IUnprintedLookupResult[] = this.getSelectedRows()
const doc = DocumentCreator.prototype.create(selectedRows);
Packer.toBlob(doc).then(blob => {
console.log(blob);
saveAs(blob, "CoverLetter_" + this.label2 + ".docx");
);
}
Currently the code above allowed me to print out the selected array into a doc type file as the image below:
[]
We are able to print out. But what Im trying to archieve is: once the user click on the button it will directly download it as PDF and open in a tab. Any suggestion?
Upvotes: 0
Views: 477
Reputation: 46
You can look jsPDF https://www.npmjs.com/package/jspdf
import { jsPDF } from "jspdf";
var doc = new jsPDF();
doc.setFontSize(22);
doc.text(20, 20, selectedRows.map(e => return JSON.stringify(e));
doc.save("myarray.pdf");
Upvotes: 0