Hi i have a problem generating a PDF file in my ionic app using cordova plugin htmlToPDF.
I have images taken with my iphone camera and stored in the dataDirectory with the Filewrite function, and the path is stocked in an sqlite database.
The problem is that my images aren’t visible in the PDF generated and i don’t know why.
here is the html code generated in js :
// My array of images
var photos = ["file:///var/mobile/Containers/Data/Application/FB33F4C7-464C-4AFB-8812-6F4CED6EF930/Library/NoCloud/test1.jpg", "file:///var/mobile/Containers/Data/Application/FB33F4C7-464C-4AFB-8812-6F4CED6EF930/Library/NoCloud/test2.jpg"
];
// Creating html for the PDF
let htmlEmail1 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
htmlEmail1 += '<html xmlns="http://www.w3.org/1999/xhtml" style="background-color:#89BD29;margin:0px">';
htmlEmail1 += '<head>';
htmlEmail1 += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
htmlEmail1 += '<title></title>';
htmlEmail1 += '<style>body, html{font-family:helvetica, sans-serif;background-color:#89BD29;margin:0px}</style>'
htmlEmail1 += '</head>';
htmlEmail1 += '<body>';
for (var i = 0; i < photos.length; i++) {
htmlEmail1 += '<img src="' + photos[i] + '"/>';
}
htmlEmail1 += '</body>';
htmlEmail1 += '</html>';
cordova.plugins.pdf.htmlToPDF({
data: htmlEmail1,
documentSize: "A4",
landscape: "portrait",
type: "base64"
},
(success2) => {
doSomething()
});
But the result is an empty transparent square in the PDF…
Best,
Ben