@libpdf/core 0.0.1-beta.5 → 0.0.1-beta.6

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/index.d.mts CHANGED
@@ -5535,13 +5535,13 @@ declare class PathBuilder {
5535
5535
  */
5536
5536
  interface Rectangle {
5537
5537
  /** Left x coordinate */
5538
- x1: number;
5538
+ x: number;
5539
5539
  /** Bottom y coordinate */
5540
- y1: number;
5541
- /** Right x coordinate */
5542
- x2: number;
5543
- /** Top y coordinate */
5544
- y2: number;
5540
+ y: number;
5541
+ /** Width */
5542
+ width: number;
5543
+ /** Height */
5544
+ height: number;
5545
5545
  }
5546
5546
  /**
5547
5547
  * Options for drawing an embedded page.
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import * as pkijs from "pkijs";
9
9
  import { base64 } from "@scure/base";
10
10
 
11
11
  //#region package.json
12
- var version = "0.0.1-beta.5";
12
+ var version = "0.0.1-beta.6";
13
13
 
14
14
  //#endregion
15
15
  //#region src/objects/pdf-array.ts
@@ -32774,10 +32774,10 @@ var PDFPage = class PDFPage {
32774
32774
  */
32775
32775
  getMediaBox() {
32776
32776
  return this.getBox("MediaBox") ?? {
32777
- x1: 0,
32778
- y1: 0,
32779
- x2: 612,
32780
- y2: 792
32777
+ x: 0,
32778
+ y: 0,
32779
+ width: 612,
32780
+ height: 792
32781
32781
  };
32782
32782
  }
32783
32783
  /**
@@ -32819,10 +32819,13 @@ var PDFPage = class PDFPage {
32819
32819
  * returns the height of the MediaBox instead.
32820
32820
  */
32821
32821
  get width() {
32822
- const box = this.getMediaBox();
32822
+ const mediaBox = this.getMediaBox();
32823
+ const cropBox = this.getCropBox();
32824
+ let box = mediaBox;
32825
+ if (cropBox.width < mediaBox.width || cropBox.height < mediaBox.height) box = cropBox;
32823
32826
  const rotation = this.rotation;
32824
- if (rotation === 90 || rotation === 270) return Math.abs(box.y2 - box.y1);
32825
- return Math.abs(box.x2 - box.x1);
32827
+ if (rotation === 90 || rotation === 270) return Math.abs(box.height);
32828
+ return Math.abs(box.width);
32826
32829
  }
32827
32830
  /**
32828
32831
  * Page height in points (based on MediaBox).
@@ -32831,10 +32834,13 @@ var PDFPage = class PDFPage {
32831
32834
  * returns the width of the MediaBox instead.
32832
32835
  */
32833
32836
  get height() {
32834
- const box = this.getMediaBox();
32837
+ const mediaBox = this.getMediaBox();
32838
+ const cropBox = this.getCropBox();
32839
+ let box = mediaBox;
32840
+ if (cropBox.width < mediaBox.width || cropBox.height < mediaBox.height) box = cropBox;
32835
32841
  const rotation = this.rotation;
32836
- if (rotation === 90 || rotation === 270) return Math.abs(box.x2 - box.x1);
32837
- return Math.abs(box.y2 - box.y1);
32842
+ if (rotation === 90 || rotation === 270) return Math.abs(box.width);
32843
+ return Math.abs(box.height);
32838
32844
  }
32839
32845
  /**
32840
32846
  * Whether the page is in landscape orientation.
@@ -32935,8 +32941,8 @@ var PDFPage = class PDFPage {
32935
32941
  });
32936
32942
  ops.push(`/${gsName} gs`);
32937
32943
  }
32938
- const translateX = x - embedded.box.x1 * scaleX;
32939
- const translateY = y - embedded.box.y1 * scaleY;
32944
+ const translateX = x - embedded.box.x * scaleX;
32945
+ const translateY = y - embedded.box.y * scaleY;
32940
32946
  ops.push(`${this.formatNumber(scaleX)} 0 0 ${this.formatNumber(scaleY)} ${this.formatNumber(translateX)} ${this.formatNumber(translateY)} cm`);
32941
32947
  ops.push(`/${xobjectName} Do`);
32942
32948
  ops.push("Q");
@@ -34016,10 +34022,10 @@ var PDFPage = class PDFPage {
34016
34022
  const y2 = box.at(3);
34017
34023
  if (!(x1 instanceof PdfNumber) || !(y1 instanceof PdfNumber) || !(x2 instanceof PdfNumber) || !(y2 instanceof PdfNumber)) return null;
34018
34024
  return {
34019
- x1: x1.value,
34020
- y1: y1.value,
34021
- x2: x2.value,
34022
- y2: y2.value
34025
+ x: x1.value,
34026
+ y: y1.value,
34027
+ width: x2.value,
34028
+ height: y2.value
34023
34029
  };
34024
34030
  }
34025
34031
  /**
@@ -37572,10 +37578,10 @@ var PDF = class PDF {
37572
37578
  Subtype: PdfName.of("Form"),
37573
37579
  FormType: PdfNumber.of(1),
37574
37580
  BBox: new PdfArray([
37575
- PdfNumber.of(mediaBox.x1),
37576
- PdfNumber.of(mediaBox.y1),
37577
- PdfNumber.of(mediaBox.x2),
37578
- PdfNumber.of(mediaBox.y2)
37581
+ PdfNumber.of(mediaBox.x),
37582
+ PdfNumber.of(mediaBox.y),
37583
+ PdfNumber.of(mediaBox.x + mediaBox.width),
37584
+ PdfNumber.of(mediaBox.y + mediaBox.height)
37579
37585
  ]),
37580
37586
  Resources: resources
37581
37587
  }, contentData);