Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR ASSEMBLY

datauristring pdf open in php


$("#printer").on("click",function(e){

var element = document.getElementById('qrcode');

var opt = {

  image:        { type: 'jpeg', quality: 0.98 },
  html2canvas:  { scale: 3 },
  jsPDF:        { unit: 'cm', format: 'letter', orientation: 'landscape' }
};

html2pdf().from(element).set(opt).toPdf().output('datauristring').then(function (pdfAsString) {
    // The PDF has been converted to a Data URI string and passed to this function.
    // Use pdfAsString however you like (send as email, etc)!

var arr = pdfAsString.split(',');
pdfAsString= arr[1];    

        var data = new FormData();
        data.append("data" , pdfAsString);
        var xhr = new XMLHttpRequest();
        xhr.open( 'post', 'upload.php', true ); //Post the Data URI to php Script to save to server
        xhr.send(data);

        })

e.preventDefault();  //stop the browser from following
    window.location.href = 'uploads/file.pdf';

});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #datauristring #pdf #open #php
ADD COMMENT
Topic
Name
2+4 =