简体   繁体   中英

Blob string url to PDF

I am creating a blob url string which contains multiple SVGs

blob:file%3A///45525ac9-caa6-4a48-aa8f-aab1ff6c9e7e

I am able to print this also using iframe.

function closePrint () {
  document.body.removeChild(this.__container__);
}

function setPrint () {
  this.contentWindow.__container__ = this;
  this.contentWindow.onbeforeunload = closePrint;
  this.contentWindow.onafterprint = closePrint;
  this.contentWindow.focus(); // Required for IE
  this.contentWindow.print();
}

function printPage (sURL) {
  var oHiddFrame = document.createElement("iframe");
  oHiddFrame.onload = setPrint;
  oHiddFrame.style.visibility = "hidden";
  oHiddFrame.style.position = "fixed";
  oHiddFrame.style.right = "0";
  oHiddFrame.style.bottom = "0";
  oHiddFrame.src = sURL;
  document.body.appendChild(oHiddFrame);
}

 printPage(fileURL);

But how can I download the same url content as PDF in javascript?

You're basically asking how to convert SVG to PDF, right? Either you do it serverside, or if you absolutely want to do it in JavaScript: take a look at PDFKit .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM