1

I use a code like below to get pdf base64 data and generate my HTML and then print it.

dataService.getPagedData("/api/fileAction/getFile", {}).then(function (data) {

viewMarkup = '<object style="width:100%;height:100%" '
          + ' type="application/pdf" '
          + ' data="data:application/pdf;base64,'
          + escape(data) + '" ></object >'

var PW = window.open('', '_blank', 'Print content');

PW.document.write(viewMarkup);
PW.document.close();
PW.focus();
PW.print();
PW.close();

}

my HTML code becomes something like this :

<object style="width:100%;height:100%" type="application/pdf"  
data="data:application/pdf;base64,!!Very Long PDF Base64 Data!!">
</object >

and when I see my HTML page alone everything is ok and my pdf file is shown on the page, but when I use 'CTRL+P' on that page, or when i go through my javascript code to print the pdf, there is nothing in the print preview form of chrome!

do you know how can I solve it?

Farzad Karimi
  • 770
  • 1
  • 12
  • 31
  • Could you elaborate on why loading a base64 PDF in chrome and trying to print is important for you? There may be a better/easier solution to what you want to do. – Ryan Jul 11 '18 at 18:23
  • I have some pdf files as an email attachments and i he must have an ability to print each of them as he want. – Farzad Karimi Jul 11 '18 at 19:13

0 Answers0