0

novice question perhaps - ultimately trying to pass an image from a main page to pop-up for printing

main page > uses a canvas which is then converted...

  var image = dwnCanvas.toDataURL("image/png");
  sessionStorage.setItem("imgTAG", image);

console.log(image) returns lengthy base64 image info on main page

pop-up page > not sure why session variable truncated

 <img id="QR-code" src="" />
 <script>
       myImage = new Image();
       myImage = sessionStorage.getItem("imgTAG");
       document.getElementById("QR-code").src = myImage;
 </script>

console.log(myImage) returns original lengthy base64 image info. console.log(document.getElementById("QR-code")) returns a truncated src of ~ 60 characters i.e. <img id="QR-code" src="data:image/png;base64,iV…AAFMgHIEAAAAAElFTkSuQmCC">

The PNG image is present in pop-up but transparent - I assume due to incomplete src/base64 info?

Thanks in advance j

J Morris
  • 1
  • 2
  • Does this answer your question? [What is the max size of localStorage values?](https://stackoverflow.com/questions/2989284/what-is-the-max-size-of-localstorage-values) – Józef Podlecki Jun 14 '20 at 14:59
  • 1
    It is quite possible that your image's size is more than 5MBs which is the limit of localStorage. – Diyorbek Sadullaev Jun 14 '20 at 15:02
  • Good thought - Thanks but image is a QR code... it is small - 1.6 KB. I have a function to download the QR code image on the main page and it is rendered properly in the resulting file. – J Morris Jun 14 '20 at 15:25

0 Answers0