@yudaocode/univer-pdfs 1.6.214 → 1.6.216

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.
@@ -115,6 +115,7 @@ import {
115
115
  comparePdfUnits,
116
116
  convertPdfBytesToDocxBytes,
117
117
  convertPdfUnitToCsv,
118
+ createPdfAbortError,
118
119
  DeleteSelectedPdfElementsCommand as DeleteSelectedPdfElementsCommand2,
119
120
  detectFormFieldsFromPageSpans,
120
121
  DistributeSelectedPdfElementsCommand,
@@ -2581,20 +2582,27 @@ var FPdf = class {
2581
2582
  return this._injector.get(IPdfIoService).getIoCapabilities();
2582
2583
  }
2583
2584
  async importPdfFile(file, options) {
2585
+ if (options?.signal?.aborted) {
2586
+ throw createPdfAbortError(options.signal);
2587
+ }
2584
2588
  const ioService = this._injector.get(IPdfIoService);
2585
2589
  const outcome = await ioService.importPdf(file, {
2586
2590
  unitId: this.getId(),
2587
2591
  snapshot: this.save(),
2588
- target: options?.target
2592
+ target: options?.target,
2593
+ password: options?.password,
2594
+ signal: options?.signal
2589
2595
  });
2590
- if (outcome.mode === "snapshot") {
2591
- this.loadSnapshot(outcome.snapshot);
2592
- } else {
2593
- this._commandService.syncExecuteCommand(ImportPdfSourceCommand.id, {
2594
- unitId: this.getId(),
2595
- sourceDocumentRef: outcome.sourceDocumentRef,
2596
- pageSizes: outcome.pageSizes
2597
- });
2596
+ if (options?.signal?.aborted) {
2597
+ throw createPdfAbortError(options.signal);
2598
+ }
2599
+ const applied = outcome.mode === "snapshot" ? this.loadSnapshot(outcome.snapshot) : this._commandService.syncExecuteCommand(ImportPdfSourceCommand.id, {
2600
+ unitId: this.getId(),
2601
+ sourceDocumentRef: outcome.sourceDocumentRef,
2602
+ pageSizes: outcome.pageSizes
2603
+ });
2604
+ if (!applied) {
2605
+ throw new Error(`[UniverPdfs] Failed to apply imported PDF outcome onto unit "${this.getId()}".`);
2598
2606
  }
2599
2607
  return outcome;
2600
2608
  }
@@ -2608,7 +2616,8 @@ var FPdf = class {
2608
2616
  snapshot: this.save(),
2609
2617
  data,
2610
2618
  options,
2611
- target: options?.target
2619
+ target: options?.target,
2620
+ signal: options?.signal
2612
2621
  });
2613
2622
  }
2614
2623
  /**