Closed brunoalex closed 3 years ago
Please clean up your code sample (reduce it to what's really necessary to reproduce the issue) and surround it with ```
. My first guess would be you might run into CORS restrictions. If that's not the case, please clarify the issue. Please also check if there are any errors on the developer console, exceptions, etc.
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.
im trying to convert images from galery into a pdf but my pdf dont display my images
my code:
navigator.camera.getPicture(onSuccess, onFail, { quality: 25, destinationType: Camera.DestinationType.DATA_URL });
function onSuccess(imageData) { var image = document.getElementById('myImage'); image.src = "data:image/jpeg;base64," + imageData; }
function onFail(message) { alert('Failed because: ' + message); }
}
function getpic(){ navigator.camera.getPicture(onSuccess, onFail, { quality: 25, destinationType: Camera.DestinationType.DATA_URL, sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
function onSuccess(imageURL) {
basei=imageURL; var doc = new jsPDF(); var imgData = 'data:image/jpeg;base64,'+ imageURL;
// var pdf = new jsPDF('p','pt','a4'); // pdf.text(20, 20, 'YES, Inside of Cordova!'); // pdf.addImage(imageURL, 'png', 30, 80); // var pdfOutput = pdf.output("blob");
// //FIRST GENERATE THE PDF DOCUMENT console.log("generating pdf..."); var doc = new jsPDF();
// doc.text(20, 20, 'HELLO!');
// doc.setFont("courier"); // doc.setFontType("normal"); // doc.text(20, 30, 'This is a PDF document generated using JSPDF.'); // doc.text(20, 50, 'YES, Inside of cordova!');
doc.addImage(imgData, 'JPEG', 15, 40, 175, 75);
var pdfOutput = doc.output(); console.log( pdfOutput );
//NEXT SAVE IT TO THE DEVICE'S LOCAL FILE SYSTEM console.log("file system..."); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
entry.createWriter(function(writer) { writer.onwrite = function(evt) { console.log("write success"); };
}, function(event){ console.log( evt.target.error.code ); });
setTimeout(function() { cordova.plugins.fileOpener2.open( filep, // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Downloads/starwars.pdf 'application/pdf', { error : function(e) { console.log('Error status: ' + e.status + ' - Error message: ' + e.message); }, success : function () { console.log('file opened successfully'); }}, 4000); }
);
//
}
function onFail(message) { alert('Failed because: ' + message); } }