I am currently utilizing the to generate some docx files and enable downloading, but I am faced with the challenge of converting these files into PDF format.
This is my current process:
public download(data: any): void {
const documentCreator = new DocumentCreator();
const doc = documentCreator.create(data);
Packer.toBlob(doc).then((blob) => {
console.log(blob);
saveAs(
blob,
`Contract ${data.place} ${_moment(data.dateEvent).format('LL')}.docx`
);
console.log('Document created successfully');
this.closeModalExport();
});
}
export class DocumentCreator {
// tslint:disable-next-line: typedef
public create(diary): Document {
//Some paragraph and text
return document;
}
}
However, I am seeking guidance on how to convert the generated blob into a PDF file.
I have attempted to directly convert it and change the blob type, but unfortunately, it did not yield the desired outcome:
let pdf = new Blob([blob], {type: 'application/pdf'});
saveAs(
pdf,
`Contract ${data.place} ${_moment(data.dateEvent).format('LL')}.pdf`
);