Search
 
SCRIPT & CODE EXAMPLE
 

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';

});
Comment

datauristring pdf open in php

<?php
$data = $_POST['data'];
$b64 = $data;

# Decode the Base64 string, making sure that it contains only valid characters
$bin = base64_decode($b64, true);

# Perform a basic validation to make sure that the result is a valid PDF file
# Be aware! The magic number (file signature) is not 100% reliable solution to validate PDF files
# Moreover, if you get Base64 from an untrusted source, you must sanitize the PDF contents
if (strpos($bin, '%PDF') !== 0) {
  throw new Exception('Missing the PDF file signature');
}

# Write the PDF contents to a local file
file_put_contents('uploads/file.pdf', $bin);
?>
Comment

PREVIOUS NEXT
Code Example
Assembly :: vba check if object exists 
Assembly :: nano error reading lock file not enough data read 
Assembly :: how to check assembly compatibility X64 and x86 
Assembly :: flutter button border radius 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application 
Javascript :: electronjs require is not defined 
Javascript :: alphabet array 
Javascript :: regex cpf 
Javascript :: redirect javascript 
Javascript :: react refresh page 
Javascript :: react native build aab 
Javascript :: import redux thunk 
Javascript :: changing columns for table requires doctrine dbal install doctrine/dbal 
Javascript :: how to display object in alert javascript 
Javascript :: react native text underline 
Javascript :: change src of iframe jquery 
Javascript :: mongodb check for array not empty query 
Javascript :: how to check variable type jquery 
Javascript :: loop array backwards javascript 
Javascript :: remove commas from string javascript 
Javascript :: dynamics crm javascript set field visible 
Javascript :: jquery enforce important 
Javascript :: explode in jquery 
Javascript :: react navigation no header 
Javascript :: check if checkbox is checked jquery 
Javascript :: radio button onchange jquery 
Javascript :: how to store objects in localstorage 
Javascript :: Javascript get random item from array 
Javascript :: javascript appendchild image node 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =