Blob字符串url到PDF

Blob string url to PDF

本文关键字:PDF url 字符串 Blob      更新时间:2023-09-26

我正在创建一个包含多个SVG 的blob url字符串

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

我也可以使用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);

但是,我怎样才能下载与javascript中的PDF相同的url内容呢?

您基本上是在问如何将SVG转换为PDF,对吧?要么你在服务器端做,要么如果你绝对想用JavaScript做:看看PDFKit。