dompdf.js 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dompdf.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * dompdf.js 1.0.0 <https://html2canvas.hertzen.com>
3
- * Copyright (c) 2025 lfc <https://hertzen.com>
2
+ * dompdf.js 1.0.1 <https://dompdfjs.lisky.com.cn>
3
+ * Copyright (c) 2025 lfc <https://dompdfjs.lisky.com.cn/>
4
4
  * Released under MIT License
5
5
  */
6
6
  (function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
@@ -9013,8 +9013,6 @@
9013
9013
  format: [pageWidth, pageHeight],
9014
9014
  hotfixes: ["px_scaling"]
9015
9015
  });
9016
- // 保存PDF文件到本地
9017
- // const pdfFileName = options.pdfFileName || 'document.pdf';
9018
9016
  // 设置PDF文件的保存方式
9019
9017
  _this.context2dCtx = _this.jspdfCtx.context2d;
9020
9018
  _this.context2dCtx.scale(0.75, 0.75);
@@ -9437,9 +9435,9 @@
9437
9435
  y = this.pxToPt(bounds.top - topMargin);
9438
9436
  width = this.pxToPt(bounds.width);
9439
9437
  height = this.pxToPt(bounds.height);
9440
- dataURL = container.canvas.toDataURL('image/jpeg', 0.95);
9438
+ dataURL = container.canvas.toDataURL('image/png', 0.95);
9441
9439
  // 将 Canvas 添加到 PDF
9442
- this.jspdfCtx.addImage(dataURL, 'JPEG', x, y, width, height);
9440
+ this.jspdfCtx.addImage(dataURL, 'PNG', x, y, width, height);
9443
9441
  }
9444
9442
  catch (err) {
9445
9443
  this.context.logger.error("Error adding canvas to PDF: ".concat(err));
@@ -10264,6 +10262,7 @@
10264
10262
  };
10265
10263
 
10266
10264
  var dompdf = function (element, options) {
10265
+ // 移除元素的边框和阴影样式
10267
10266
  if (options === void 0) { options = {}; }
10268
10267
  return renderElement$1(element, options);
10269
10268
  };
@@ -10313,6 +10312,15 @@
10313
10312
  context.logger.debug("Starting document clone with size ".concat(windowBounds.width, "x").concat(windowBounds.height, " scrolled to ").concat(-windowBounds.left, ",").concat(-windowBounds.top));
10314
10313
  documentCloner = new DocumentCloner$1(context, element, cloneOptions);
10315
10314
  clonedElement = documentCloner.clonedReferenceElement;
10315
+ // console.log('设置自定义字体',opts.fontConfig,clonedElement,clonedElement.style)
10316
+ if (clonedElement && clonedElement.style) {
10317
+ clonedElement.style.border = 'none';
10318
+ clonedElement.style.boxShadow = 'none';
10319
+ if (!opts.fontConfig || !opts.fontConfig.fontBase64) {
10320
+ console.log('设置自定义字体');
10321
+ clonedElement.style.fontFamily = 'Helvetica';
10322
+ }
10323
+ }
10316
10324
  if (!clonedElement) {
10317
10325
  return [2 /*return*/, Promise.reject("Unable to find element in cloned iframe")];
10318
10326
  }
@@ -10352,7 +10360,6 @@
10352
10360
  return [4 /*yield*/, parseTree$1(context, clonedElement)];
10353
10361
  case 4:
10354
10362
  root = _v.sent();
10355
- console.log('解析后的', root);
10356
10363
  Reflect.deleteProperty(root, 'context');
10357
10364
  // Reflect.deleteProperty(root, 'elements')
10358
10365
  // =[];