tedeeee
tedeeee

Reputation: 47

How to print an array into PDF format customized doc file

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:

[Image link: doc file type]

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

Answers (1)

Cemal BAYGIN
Cemal BAYGIN

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

Related Questions