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.
@@ -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);
@@ -9007,8 +9007,6 @@ var CanvasRenderer$1 = /** @class */ (function (_super) {
9007
9007
  format: [pageWidth, pageHeight],
9008
9008
  hotfixes: ["px_scaling"]
9009
9009
  });
9010
- // 保存PDF文件到本地
9011
- // const pdfFileName = options.pdfFileName || 'document.pdf';
9012
9010
  // 设置PDF文件的保存方式
9013
9011
  _this.context2dCtx = _this.jspdfCtx.context2d;
9014
9012
  _this.context2dCtx.scale(0.75, 0.75);
@@ -9431,9 +9429,9 @@ var CanvasRenderer$1 = /** @class */ (function (_super) {
9431
9429
  y = this.pxToPt(bounds.top - topMargin);
9432
9430
  width = this.pxToPt(bounds.width);
9433
9431
  height = this.pxToPt(bounds.height);
9434
- dataURL = container.canvas.toDataURL('image/jpeg', 0.95);
9432
+ dataURL = container.canvas.toDataURL('image/png', 0.95);
9435
9433
  // 将 Canvas 添加到 PDF
9436
- this.jspdfCtx.addImage(dataURL, 'JPEG', x, y, width, height);
9434
+ this.jspdfCtx.addImage(dataURL, 'PNG', x, y, width, height);
9437
9435
  }
9438
9436
  catch (err) {
9439
9437
  this.context.logger.error("Error adding canvas to PDF: ".concat(err));
@@ -10258,6 +10256,7 @@ var fixIOSSystemFonts$1 = function (fontFamilies) {
10258
10256
  };
10259
10257
 
10260
10258
  var dompdf = function (element, options) {
10259
+ // 移除元素的边框和阴影样式
10261
10260
  if (options === void 0) { options = {}; }
10262
10261
  return renderElement$1(element, options);
10263
10262
  };
@@ -10307,6 +10306,15 @@ var renderElement$1 = function (element, opts) { return __awaiter$1(void 0, void
10307
10306
  context.logger.debug("Starting document clone with size ".concat(windowBounds.width, "x").concat(windowBounds.height, " scrolled to ").concat(-windowBounds.left, ",").concat(-windowBounds.top));
10308
10307
  documentCloner = new DocumentCloner$1(context, element, cloneOptions);
10309
10308
  clonedElement = documentCloner.clonedReferenceElement;
10309
+ // console.log('设置自定义字体',opts.fontConfig,clonedElement,clonedElement.style)
10310
+ if (clonedElement && clonedElement.style) {
10311
+ clonedElement.style.border = 'none';
10312
+ clonedElement.style.boxShadow = 'none';
10313
+ if (!opts.fontConfig || !opts.fontConfig.fontBase64) {
10314
+ console.log('设置自定义字体');
10315
+ clonedElement.style.fontFamily = 'Helvetica';
10316
+ }
10317
+ }
10310
10318
  if (!clonedElement) {
10311
10319
  return [2 /*return*/, Promise.reject("Unable to find element in cloned iframe")];
10312
10320
  }
@@ -10346,7 +10354,6 @@ var renderElement$1 = function (element, opts) { return __awaiter$1(void 0, void
10346
10354
  return [4 /*yield*/, parseTree$1(context, clonedElement)];
10347
10355
  case 4:
10348
10356
  root = _v.sent();
10349
- console.log('解析后的', root);
10350
10357
  Reflect.deleteProperty(root, 'context');
10351
10358
  // Reflect.deleteProperty(root, 'elements')
10352
10359
  // =[];