javascriptgoogle-cloud-print

Could not read data while printing image - GCP


I'm not able to print a base64 encoded image with GCP.

This is what I'm using :

var data = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD//gBERmlsZSBzb3VyY ....";

var gadget = new cloudprint.Gadget();
gadget.setPrintButton(cloudprint.Gadget.createDefaultPrintButton("gcpPrint"));
gadget.setPrintDocument("image/jpeg", "JPG Image", data, "base64");
gadget.openPrintDialog();

As mentioned in the docs. But GCP could not read data. Any ideas?


Solution

  • Need to remove :

    data:image/jpeg;base64,
    

    from the base64 string.