import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs = pdfFonts.pdfMake.vfs;
public gerarPDF(){
let texto = {
content: 'PDF ORÇAMENTO 00001'
}
pdfMake.createPdf(texto).download();
}
Could you elaborate that error description a bit?
What does work where and where not?
This code works in the browser but does not work in the app (does not download the file)
i’m try it now:
message: ‘Property ‘writeFile’ does not exist on type ‘FileEntry | FileError’.
Property ‘writeFile’ does not exist on type ‘FileEntry’.’
public gerarPDF(){
let cordova: any;
let dd = null;
dd = {content: ['AHH']};
pdfMake.createPdf(dd).getBuffer((buffer) => {
var utf8 = new Uint8Array(buffer); // Convert to UTF-8...
let binaryArray = utf8.buffer; // Convert to Binary...
let fileName = "file.pdf";
let saveDir = cordova.file.externalApplicationStorageDirectory;
File.createFile(saveDir, fileName, true).then((fileEntry) => {
fileEntry.writeFile((fileWriter) => {
fileWriter.onwriteend = () => {
};
fileWriter.onerror = (e) => {
console.log('file writer - error event fired: ' + e.toString());
};
fileWriter.write(binaryArray);
});
});
});
}
What does that mean? ionic serve
?
What does that mean?