docx-plus 0.0.9 → 0.0.11

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/README.md CHANGED
@@ -16,22 +16,25 @@ Easily generate and modify .docx files with JS/TS. Works for Node and on the Bro
16
16
  | ZIP handling | jszip | **fflate** (faster, smaller) |
17
17
  | Data conversion | Manual env detection (`Buffer.from` etc.) | **undio** (universal `toUint8Array`) |
18
18
  | `Packer.toStream()` | Removed (pseudo-streaming) | **Restored** with real streaming ZIP |
19
- | Test environment | jsdom | happy-dom |
20
- | OOXML compliance | ECMA-376 (legacy) | **ISO/IEC 29500-4** (latest) |
21
19
  | Theme support | Partial (missing `ThemeColor`/`ThemeFont`) | **Full** (`ThemeColor`, `ThemeFont` enums, theme attributes on `Color`, `Underline`, `Border`, `Shading`) |
22
20
  | CT_Ind | Twips-only indent | **Character-based** (`startChars`, `endChars`, `hangingChars`, `firstLineChars`) |
23
21
  | CT_Spacing | Missing `beforeLines`/`afterLines` | **Complete** (both twips & line-unit spacing) |
24
22
  | CT_Border | Missing `shadow`/`frame`/theme attrs | **Complete** (`shadow`, `frame`, `themeColor`, `themeTint`, `themeShade`) |
25
23
  | CT_Shd | Missing theme fill/color attrs | **Complete** (`themeColor`, `themeFill`, `themeTint`/`themeShade`) |
26
- | EG_RPrBase | Missing `outline`/`shadow`/`webHidden`/`fitText`/`cs` | **Complete** (all spec-defined elements) |
24
+ | EG_RPrBase | Missing `outline`/`shadow`/`webHidden`/`fitText`/`cs`/`eastAsianLayout` | **Complete** (all spec-defined elements including `eastAsianLayout`) |
27
25
  | ST_Em | `dot` only | **Complete** (`none`, `comma`, `circle`, `dot`, `underDot`) |
28
26
  | ST_TabTlc | Missing `heavy` | **Complete** (`none`, `dot`, `hyphen`, `middleDot`, `underscore`, `heavy`) |
29
27
  | CT_PPrBase | Missing 9 paragraph props | **Complete** (`suppressAutoHyphens`, `adjustRightInd`, `snapToGrid`, `mirrorIndents`, East Asian typography, `textAlignment`, `textboxTightWrap`) |
30
28
  | CT_SectPr | Missing `noEndnote`/`bidi`/`rtlGutter`/`paperSrc`/`footnotePr`/`endnotePr` | **Complete** (all spec-defined elements) |
31
- | EG_RPrBase | Missing `eastAsianLayout` | **Complete** (`eastAsianLayout` with `combine`, `combineBrackets`, `vert`, `vertCompress`) |
32
29
  | DrawingML colors | RGB + scheme only | **Complete** (`EG_ColorChoice`: RGB, scheme, HSL, system, preset + `EG_ColorTransform` with 29 transforms) |
33
30
  | DrawingML fills | Solid fill only | **Complete** (`solidFill`, `noFill`, `gradFill` with linear/path gradient + color stops) |
34
31
  | DrawingML outline | Basic line (width, cap, fill) | **Complete** (`a:ln` with `prstDash`, `lineJoin`, compound line, pen alignment, all fill types) |
32
+ | DrawingML effects | Not implemented | **Complete** (`effectLst`: glow, outerShdw, innerShdw, prstShdw, reflection, softEdge) |
33
+ | DrawingML 3D | Not implemented | **Complete** (`sp3d`: bevel top/bottom, extrusionClr, contourClr, preset materials) |
34
+ | Image cropping | Not implemented | **Supported** (`srcRect` with configurable `l/t/r/b` percentages) |
35
+ | Group Shape | Basic (transform only) | **Enhanced** (fill, effects, `chOff`/`chExt` child coordinates) |
36
+ | Test environment | jsdom | happy-dom |
37
+ | OOXML compliance | ECMA-376 (legacy) | **ISO/IEC 29500-4** (latest) — also aligned with Microsoft Word and WPS default behavior |
35
38
 
36
39
  ## Installation
37
40
 
package/dist/index.cjs CHANGED
@@ -7447,23 +7447,97 @@ var Drawing = class extends XmlComponent {
7447
7447
  }
7448
7448
  };
7449
7449
  //#endregion
7450
- //#region src/file/paragraph/run/image-run.ts
7451
- const createImageData = (data, transformation, key, srcRect) => ({
7452
- data,
7453
- fileName: key,
7454
- srcRect,
7455
- transformation: {
7450
+ //#region src/file/media/media.ts
7451
+ /**
7452
+ * Converts user-facing transformation options (pixels) to internal
7453
+ * transformation data (pixels + EMUs).
7454
+ *
7455
+ * @param options - User-facing transformation in pixels
7456
+ * @returns Internal transformation data with both pixel and EMU values
7457
+ */
7458
+ const createTransformation = (options) => {
7459
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7460
+ return {
7456
7461
  emus: {
7457
- x: Math.round(transformation.width * 9525),
7458
- y: Math.round(transformation.height * 9525)
7462
+ x: Math.round(options.width * 9525),
7463
+ y: Math.round(options.height * 9525)
7464
+ },
7465
+ flip: options.flip,
7466
+ offset: {
7467
+ emus: {
7468
+ x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7469
+ y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7470
+ },
7471
+ pixels: {
7472
+ x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7473
+ y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7474
+ }
7459
7475
  },
7460
- flip: transformation.flip,
7461
7476
  pixels: {
7462
- x: Math.round(transformation.width),
7463
- y: Math.round(transformation.height)
7477
+ x: Math.round(options.width),
7478
+ y: Math.round(options.height)
7464
7479
  },
7465
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7480
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7481
+ };
7482
+ };
7483
+ /**
7484
+ * Manages embedded media (images) in a document.
7485
+ *
7486
+ * Media stores all images referenced in the document and provides
7487
+ * access to their data for packaging into the DOCX file. Each image
7488
+ * is stored with a unique key for retrieval.
7489
+ *
7490
+ * @example
7491
+ * ```typescript
7492
+ * const media = new Media();
7493
+ * media.addImage("image1", {
7494
+ * type: "png",
7495
+ * fileName: "image1.png",
7496
+ * transformation: {
7497
+ * pixels: { x: 200, y: 100 },
7498
+ * emus: { x: 1828800, y: 914400 }
7499
+ * },
7500
+ * data: imageBuffer
7501
+ * });
7502
+ * const allImages = media.Array;
7503
+ * ```
7504
+ */
7505
+ var Media = class {
7506
+ constructor() {
7507
+ _defineProperty(this, "map", void 0);
7508
+ this.map = /* @__PURE__ */ new Map();
7466
7509
  }
7510
+ /**
7511
+ * Adds an image to the media collection.
7512
+ *
7513
+ * @param key - Unique identifier for this image
7514
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7515
+ */
7516
+ addImage(key, mediaData) {
7517
+ this.map.set(key, mediaData);
7518
+ }
7519
+ /**
7520
+ * Gets all images as an array.
7521
+ *
7522
+ * @returns Read-only array of all media data in the collection
7523
+ */
7524
+ get Array() {
7525
+ return [...this.map.values()];
7526
+ }
7527
+ };
7528
+ //#endregion
7529
+ //#region src/file/media/data.ts
7530
+ /**
7531
+ * @ignore
7532
+ */
7533
+ const WORKAROUND2 = "";
7534
+ //#endregion
7535
+ //#region src/file/paragraph/run/image-run.ts
7536
+ const createImageData = (data, transformation, key, srcRect) => ({
7537
+ data,
7538
+ fileName: key,
7539
+ srcRect,
7540
+ transformation: createTransformation(transformation)
7467
7541
  });
7468
7542
  /**
7469
7543
  * Represents an image in a WordprocessingML document.
@@ -7522,31 +7596,6 @@ var ImageRun = class extends Run {
7522
7596
  };
7523
7597
  //#endregion
7524
7598
  //#region src/file/paragraph/run/wps-shape-run.ts
7525
- const createTransformation = (options) => {
7526
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7527
- return {
7528
- emus: {
7529
- x: Math.round(options.width * 9525),
7530
- y: Math.round(options.height * 9525)
7531
- },
7532
- flip: options.flip,
7533
- offset: {
7534
- emus: {
7535
- x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7536
- y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7537
- },
7538
- pixels: {
7539
- x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7540
- y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7541
- }
7542
- },
7543
- pixels: {
7544
- x: Math.round(options.width),
7545
- y: Math.round(options.height)
7546
- },
7547
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7548
- };
7549
- };
7550
7599
  /**
7551
7600
  * @publicApi
7552
7601
  */
@@ -15348,23 +15397,23 @@ const createSectionType = (value) => new BuilderElement({
15348
15397
  * Default margin values for sections (in twips).
15349
15398
  *
15350
15399
  * Standard margins are 1 inch (1440 twips) on all sides.
15351
- * Header/footer margins are 0.5 inches (708 twips) from page edge.
15400
+ * Header/footer margins are from page edge.
15352
15401
  *
15353
15402
  * @property TOP - Top margin: 1440 twips (1 inch)
15354
- * @property RIGHT - Right margin: 1440 twips (1 inch)
15403
+ * @property RIGHT - Right margin: 1800 twips (1.25 inches)
15355
15404
  * @property BOTTOM - Bottom margin: 1440 twips (1 inch)
15356
- * @property LEFT - Left margin: 1440 twips (1 inch)
15357
- * @property HEADER - Header margin: 708 twips (0.5 inches)
15358
- * @property FOOTER - Footer margin: 708 twips (0.5 inches)
15405
+ * @property LEFT - Left margin: 1800 twips (1.25 inches)
15406
+ * @property HEADER - Header margin: 851 twips (0.59 inches)
15407
+ * @property FOOTER - Footer margin: 992 twips (0.69 inches)
15359
15408
  * @property GUTTER - Gutter margin: 0 twips
15360
15409
  */
15361
15410
  const sectionMarginDefaults = {
15362
15411
  TOP: 1440,
15363
- RIGHT: 1440,
15412
+ RIGHT: 1800,
15364
15413
  BOTTOM: 1440,
15365
- LEFT: 1440,
15366
- HEADER: 708,
15367
- FOOTER: 708,
15414
+ LEFT: 1800,
15415
+ HEADER: 851,
15416
+ FOOTER: 992,
15368
15417
  GUTTER: 0
15369
15418
  };
15370
15419
  /**
@@ -15431,7 +15480,7 @@ const sectionPageSizeDefaults = {
15431
15480
  * ```
15432
15481
  */
15433
15482
  var SectionProperties = class extends XmlComponent {
15434
- constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 360, charSpace, type: gridType } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15483
+ constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 312, charSpace = 0, type: gridType = "lines" } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15435
15484
  super("w:sectPr");
15436
15485
  this.addHeaderFooterGroup(HeaderFooterType.HEADER, headerWrapperGroup);
15437
15486
  this.addHeaderFooterGroup(HeaderFooterType.FOOTER, footerWrapperGroup);
@@ -16861,59 +16910,6 @@ var HeaderWrapper = class {
16861
16910
  }
16862
16911
  };
16863
16912
  //#endregion
16864
- //#region src/file/media/media.ts
16865
- /**
16866
- * Manages embedded media (images) in a document.
16867
- *
16868
- * Media stores all images referenced in the document and provides
16869
- * access to their data for packaging into the DOCX file. Each image
16870
- * is stored with a unique key for retrieval.
16871
- *
16872
- * @example
16873
- * ```typescript
16874
- * const media = new Media();
16875
- * media.addImage("image1", {
16876
- * type: "png",
16877
- * fileName: "image1.png",
16878
- * transformation: {
16879
- * pixels: { x: 200, y: 100 },
16880
- * emus: { x: 1828800, y: 914400 }
16881
- * },
16882
- * data: imageBuffer
16883
- * });
16884
- * const allImages = media.Array;
16885
- * ```
16886
- */
16887
- var Media = class {
16888
- constructor() {
16889
- _defineProperty(this, "map", void 0);
16890
- this.map = /* @__PURE__ */ new Map();
16891
- }
16892
- /**
16893
- * Adds an image to the media collection.
16894
- *
16895
- * @param key - Unique identifier for this image
16896
- * @param mediaData - Complete image data including file name, transformation, and raw data
16897
- */
16898
- addImage(key, mediaData) {
16899
- this.map.set(key, mediaData);
16900
- }
16901
- /**
16902
- * Gets all images as an array.
16903
- *
16904
- * @returns Read-only array of all media data in the collection
16905
- */
16906
- get Array() {
16907
- return [...this.map.values()];
16908
- }
16909
- };
16910
- //#endregion
16911
- //#region src/file/media/data.ts
16912
- /**
16913
- * @ignore
16914
- */
16915
- const WORKAROUND2 = "";
16916
- //#endregion
16917
16913
  //#region src/file/numbering/level.ts
16918
16914
  /**
16919
16915
  * Numbering level definitions module for WordprocessingML documents.
package/dist/index.d.cts CHANGED
@@ -1287,6 +1287,7 @@ interface IMediaTransformation {
1287
1287
  };
1288
1288
  readonly rotation?: number;
1289
1289
  }
1290
+ declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1290
1291
  declare class Media {
1291
1292
  private readonly map;
1292
1293
  constructor();
@@ -1345,7 +1346,6 @@ interface CoreShapeOptions {
1345
1346
  type IWpsShapeOptions = WpsShapeCoreOptions & {
1346
1347
  readonly type: "wps";
1347
1348
  } & CoreShapeOptions;
1348
- declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1349
1349
  declare class WpsShapeRun extends Run {
1350
1350
  private readonly wpsShapeData;
1351
1351
  constructor(options: IWpsShapeOptions);
package/dist/index.d.mts CHANGED
@@ -1289,6 +1289,7 @@ interface IMediaTransformation {
1289
1289
  };
1290
1290
  readonly rotation?: number;
1291
1291
  }
1292
+ declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1292
1293
  declare class Media {
1293
1294
  private readonly map;
1294
1295
  constructor();
@@ -1347,7 +1348,6 @@ interface CoreShapeOptions {
1347
1348
  type IWpsShapeOptions = WpsShapeCoreOptions & {
1348
1349
  readonly type: "wps";
1349
1350
  } & CoreShapeOptions;
1350
- declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1351
1351
  declare class WpsShapeRun extends Run {
1352
1352
  private readonly wpsShapeData;
1353
1353
  constructor(options: IWpsShapeOptions);
@@ -7442,23 +7442,97 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
7442
7442
  }
7443
7443
  };
7444
7444
  //#endregion
7445
- //#region src/file/paragraph/run/image-run.ts
7446
- const createImageData = (data, transformation, key, srcRect) => ({
7447
- data,
7448
- fileName: key,
7449
- srcRect,
7450
- transformation: {
7445
+ //#region src/file/media/media.ts
7446
+ /**
7447
+ * Converts user-facing transformation options (pixels) to internal
7448
+ * transformation data (pixels + EMUs).
7449
+ *
7450
+ * @param options - User-facing transformation in pixels
7451
+ * @returns Internal transformation data with both pixel and EMU values
7452
+ */
7453
+ const createTransformation = (options) => {
7454
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7455
+ return {
7451
7456
  emus: {
7452
- x: Math.round(transformation.width * 9525),
7453
- y: Math.round(transformation.height * 9525)
7457
+ x: Math.round(options.width * 9525),
7458
+ y: Math.round(options.height * 9525)
7459
+ },
7460
+ flip: options.flip,
7461
+ offset: {
7462
+ emus: {
7463
+ x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7464
+ y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7465
+ },
7466
+ pixels: {
7467
+ x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7468
+ y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7469
+ }
7454
7470
  },
7455
- flip: transformation.flip,
7456
7471
  pixels: {
7457
- x: Math.round(transformation.width),
7458
- y: Math.round(transformation.height)
7472
+ x: Math.round(options.width),
7473
+ y: Math.round(options.height)
7459
7474
  },
7460
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7475
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7476
+ };
7477
+ };
7478
+ /**
7479
+ * Manages embedded media (images) in a document.
7480
+ *
7481
+ * Media stores all images referenced in the document and provides
7482
+ * access to their data for packaging into the DOCX file. Each image
7483
+ * is stored with a unique key for retrieval.
7484
+ *
7485
+ * @example
7486
+ * ```typescript
7487
+ * const media = new Media();
7488
+ * media.addImage("image1", {
7489
+ * type: "png",
7490
+ * fileName: "image1.png",
7491
+ * transformation: {
7492
+ * pixels: { x: 200, y: 100 },
7493
+ * emus: { x: 1828800, y: 914400 }
7494
+ * },
7495
+ * data: imageBuffer
7496
+ * });
7497
+ * const allImages = media.Array;
7498
+ * ```
7499
+ */
7500
+ var Media = class {
7501
+ constructor() {
7502
+ _defineProperty(this, "map", void 0);
7503
+ this.map = /* @__PURE__ */ new Map();
7461
7504
  }
7505
+ /**
7506
+ * Adds an image to the media collection.
7507
+ *
7508
+ * @param key - Unique identifier for this image
7509
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7510
+ */
7511
+ addImage(key, mediaData) {
7512
+ this.map.set(key, mediaData);
7513
+ }
7514
+ /**
7515
+ * Gets all images as an array.
7516
+ *
7517
+ * @returns Read-only array of all media data in the collection
7518
+ */
7519
+ get Array() {
7520
+ return [...this.map.values()];
7521
+ }
7522
+ };
7523
+ //#endregion
7524
+ //#region src/file/media/data.ts
7525
+ /**
7526
+ * @ignore
7527
+ */
7528
+ const WORKAROUND2 = "";
7529
+ //#endregion
7530
+ //#region src/file/paragraph/run/image-run.ts
7531
+ const createImageData = (data, transformation, key, srcRect) => ({
7532
+ data,
7533
+ fileName: key,
7534
+ srcRect,
7535
+ transformation: createTransformation(transformation)
7462
7536
  });
7463
7537
  /**
7464
7538
  * Represents an image in a WordprocessingML document.
@@ -7517,31 +7591,6 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
7517
7591
  };
7518
7592
  //#endregion
7519
7593
  //#region src/file/paragraph/run/wps-shape-run.ts
7520
- const createTransformation = (options) => {
7521
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7522
- return {
7523
- emus: {
7524
- x: Math.round(options.width * 9525),
7525
- y: Math.round(options.height * 9525)
7526
- },
7527
- flip: options.flip,
7528
- offset: {
7529
- emus: {
7530
- x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7531
- y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7532
- },
7533
- pixels: {
7534
- x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7535
- y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7536
- }
7537
- },
7538
- pixels: {
7539
- x: Math.round(options.width),
7540
- y: Math.round(options.height)
7541
- },
7542
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7543
- };
7544
- };
7545
7594
  /**
7546
7595
  * @publicApi
7547
7596
  */
@@ -15343,23 +15392,23 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
15343
15392
  * Default margin values for sections (in twips).
15344
15393
  *
15345
15394
  * Standard margins are 1 inch (1440 twips) on all sides.
15346
- * Header/footer margins are 0.5 inches (708 twips) from page edge.
15395
+ * Header/footer margins are from page edge.
15347
15396
  *
15348
15397
  * @property TOP - Top margin: 1440 twips (1 inch)
15349
- * @property RIGHT - Right margin: 1440 twips (1 inch)
15398
+ * @property RIGHT - Right margin: 1800 twips (1.25 inches)
15350
15399
  * @property BOTTOM - Bottom margin: 1440 twips (1 inch)
15351
- * @property LEFT - Left margin: 1440 twips (1 inch)
15352
- * @property HEADER - Header margin: 708 twips (0.5 inches)
15353
- * @property FOOTER - Footer margin: 708 twips (0.5 inches)
15400
+ * @property LEFT - Left margin: 1800 twips (1.25 inches)
15401
+ * @property HEADER - Header margin: 851 twips (0.59 inches)
15402
+ * @property FOOTER - Footer margin: 992 twips (0.69 inches)
15354
15403
  * @property GUTTER - Gutter margin: 0 twips
15355
15404
  */
15356
15405
  const sectionMarginDefaults = {
15357
15406
  TOP: 1440,
15358
- RIGHT: 1440,
15407
+ RIGHT: 1800,
15359
15408
  BOTTOM: 1440,
15360
- LEFT: 1440,
15361
- HEADER: 708,
15362
- FOOTER: 708,
15409
+ LEFT: 1800,
15410
+ HEADER: 851,
15411
+ FOOTER: 992,
15363
15412
  GUTTER: 0
15364
15413
  };
15365
15414
  /**
@@ -15426,7 +15475,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
15426
15475
  * ```
15427
15476
  */
15428
15477
  var SectionProperties = class extends XmlComponent {
15429
- constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 360, charSpace, type: gridType } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15478
+ constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 312, charSpace = 0, type: gridType = "lines" } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15430
15479
  super("w:sectPr");
15431
15480
  this.addHeaderFooterGroup(HeaderFooterType.HEADER, headerWrapperGroup);
15432
15481
  this.addHeaderFooterGroup(HeaderFooterType.FOOTER, footerWrapperGroup);
@@ -16856,59 +16905,6 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
16856
16905
  }
16857
16906
  };
16858
16907
  //#endregion
16859
- //#region src/file/media/media.ts
16860
- /**
16861
- * Manages embedded media (images) in a document.
16862
- *
16863
- * Media stores all images referenced in the document and provides
16864
- * access to their data for packaging into the DOCX file. Each image
16865
- * is stored with a unique key for retrieval.
16866
- *
16867
- * @example
16868
- * ```typescript
16869
- * const media = new Media();
16870
- * media.addImage("image1", {
16871
- * type: "png",
16872
- * fileName: "image1.png",
16873
- * transformation: {
16874
- * pixels: { x: 200, y: 100 },
16875
- * emus: { x: 1828800, y: 914400 }
16876
- * },
16877
- * data: imageBuffer
16878
- * });
16879
- * const allImages = media.Array;
16880
- * ```
16881
- */
16882
- var Media = class {
16883
- constructor() {
16884
- _defineProperty(this, "map", void 0);
16885
- this.map = /* @__PURE__ */ new Map();
16886
- }
16887
- /**
16888
- * Adds an image to the media collection.
16889
- *
16890
- * @param key - Unique identifier for this image
16891
- * @param mediaData - Complete image data including file name, transformation, and raw data
16892
- */
16893
- addImage(key, mediaData) {
16894
- this.map.set(key, mediaData);
16895
- }
16896
- /**
16897
- * Gets all images as an array.
16898
- *
16899
- * @returns Read-only array of all media data in the collection
16900
- */
16901
- get Array() {
16902
- return [...this.map.values()];
16903
- }
16904
- };
16905
- //#endregion
16906
- //#region src/file/media/data.ts
16907
- /**
16908
- * @ignore
16909
- */
16910
- const WORKAROUND2 = "";
16911
- //#endregion
16912
16908
  //#region src/file/numbering/level.ts
16913
16909
  /**
16914
16910
  * Numbering level definitions module for WordprocessingML documents.
package/dist/index.mjs CHANGED
@@ -7422,23 +7422,97 @@ var Drawing = class extends XmlComponent {
7422
7422
  }
7423
7423
  };
7424
7424
  //#endregion
7425
- //#region src/file/paragraph/run/image-run.ts
7426
- const createImageData = (data, transformation, key, srcRect) => ({
7427
- data,
7428
- fileName: key,
7429
- srcRect,
7430
- transformation: {
7425
+ //#region src/file/media/media.ts
7426
+ /**
7427
+ * Converts user-facing transformation options (pixels) to internal
7428
+ * transformation data (pixels + EMUs).
7429
+ *
7430
+ * @param options - User-facing transformation in pixels
7431
+ * @returns Internal transformation data with both pixel and EMU values
7432
+ */
7433
+ const createTransformation = (options) => {
7434
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7435
+ return {
7431
7436
  emus: {
7432
- x: Math.round(transformation.width * 9525),
7433
- y: Math.round(transformation.height * 9525)
7437
+ x: Math.round(options.width * 9525),
7438
+ y: Math.round(options.height * 9525)
7439
+ },
7440
+ flip: options.flip,
7441
+ offset: {
7442
+ emus: {
7443
+ x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7444
+ y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7445
+ },
7446
+ pixels: {
7447
+ x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7448
+ y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7449
+ }
7434
7450
  },
7435
- flip: transformation.flip,
7436
7451
  pixels: {
7437
- x: Math.round(transformation.width),
7438
- y: Math.round(transformation.height)
7452
+ x: Math.round(options.width),
7453
+ y: Math.round(options.height)
7439
7454
  },
7440
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7455
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7456
+ };
7457
+ };
7458
+ /**
7459
+ * Manages embedded media (images) in a document.
7460
+ *
7461
+ * Media stores all images referenced in the document and provides
7462
+ * access to their data for packaging into the DOCX file. Each image
7463
+ * is stored with a unique key for retrieval.
7464
+ *
7465
+ * @example
7466
+ * ```typescript
7467
+ * const media = new Media();
7468
+ * media.addImage("image1", {
7469
+ * type: "png",
7470
+ * fileName: "image1.png",
7471
+ * transformation: {
7472
+ * pixels: { x: 200, y: 100 },
7473
+ * emus: { x: 1828800, y: 914400 }
7474
+ * },
7475
+ * data: imageBuffer
7476
+ * });
7477
+ * const allImages = media.Array;
7478
+ * ```
7479
+ */
7480
+ var Media = class {
7481
+ constructor() {
7482
+ _defineProperty(this, "map", void 0);
7483
+ this.map = /* @__PURE__ */ new Map();
7441
7484
  }
7485
+ /**
7486
+ * Adds an image to the media collection.
7487
+ *
7488
+ * @param key - Unique identifier for this image
7489
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7490
+ */
7491
+ addImage(key, mediaData) {
7492
+ this.map.set(key, mediaData);
7493
+ }
7494
+ /**
7495
+ * Gets all images as an array.
7496
+ *
7497
+ * @returns Read-only array of all media data in the collection
7498
+ */
7499
+ get Array() {
7500
+ return [...this.map.values()];
7501
+ }
7502
+ };
7503
+ //#endregion
7504
+ //#region src/file/media/data.ts
7505
+ /**
7506
+ * @ignore
7507
+ */
7508
+ const WORKAROUND2 = "";
7509
+ //#endregion
7510
+ //#region src/file/paragraph/run/image-run.ts
7511
+ const createImageData = (data, transformation, key, srcRect) => ({
7512
+ data,
7513
+ fileName: key,
7514
+ srcRect,
7515
+ transformation: createTransformation(transformation)
7442
7516
  });
7443
7517
  /**
7444
7518
  * Represents an image in a WordprocessingML document.
@@ -7497,31 +7571,6 @@ var ImageRun = class extends Run {
7497
7571
  };
7498
7572
  //#endregion
7499
7573
  //#region src/file/paragraph/run/wps-shape-run.ts
7500
- const createTransformation = (options) => {
7501
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7502
- return {
7503
- emus: {
7504
- x: Math.round(options.width * 9525),
7505
- y: Math.round(options.height * 9525)
7506
- },
7507
- flip: options.flip,
7508
- offset: {
7509
- emus: {
7510
- x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7511
- y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7512
- },
7513
- pixels: {
7514
- x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7515
- y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7516
- }
7517
- },
7518
- pixels: {
7519
- x: Math.round(options.width),
7520
- y: Math.round(options.height)
7521
- },
7522
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7523
- };
7524
- };
7525
7574
  /**
7526
7575
  * @publicApi
7527
7576
  */
@@ -15323,23 +15372,23 @@ const createSectionType = (value) => new BuilderElement({
15323
15372
  * Default margin values for sections (in twips).
15324
15373
  *
15325
15374
  * Standard margins are 1 inch (1440 twips) on all sides.
15326
- * Header/footer margins are 0.5 inches (708 twips) from page edge.
15375
+ * Header/footer margins are from page edge.
15327
15376
  *
15328
15377
  * @property TOP - Top margin: 1440 twips (1 inch)
15329
- * @property RIGHT - Right margin: 1440 twips (1 inch)
15378
+ * @property RIGHT - Right margin: 1800 twips (1.25 inches)
15330
15379
  * @property BOTTOM - Bottom margin: 1440 twips (1 inch)
15331
- * @property LEFT - Left margin: 1440 twips (1 inch)
15332
- * @property HEADER - Header margin: 708 twips (0.5 inches)
15333
- * @property FOOTER - Footer margin: 708 twips (0.5 inches)
15380
+ * @property LEFT - Left margin: 1800 twips (1.25 inches)
15381
+ * @property HEADER - Header margin: 851 twips (0.59 inches)
15382
+ * @property FOOTER - Footer margin: 992 twips (0.69 inches)
15334
15383
  * @property GUTTER - Gutter margin: 0 twips
15335
15384
  */
15336
15385
  const sectionMarginDefaults = {
15337
15386
  TOP: 1440,
15338
- RIGHT: 1440,
15387
+ RIGHT: 1800,
15339
15388
  BOTTOM: 1440,
15340
- LEFT: 1440,
15341
- HEADER: 708,
15342
- FOOTER: 708,
15389
+ LEFT: 1800,
15390
+ HEADER: 851,
15391
+ FOOTER: 992,
15343
15392
  GUTTER: 0
15344
15393
  };
15345
15394
  /**
@@ -15406,7 +15455,7 @@ const sectionPageSizeDefaults = {
15406
15455
  * ```
15407
15456
  */
15408
15457
  var SectionProperties = class extends XmlComponent {
15409
- constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 360, charSpace, type: gridType } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15458
+ constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 312, charSpace = 0, type: gridType = "lines" } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15410
15459
  super("w:sectPr");
15411
15460
  this.addHeaderFooterGroup(HeaderFooterType.HEADER, headerWrapperGroup);
15412
15461
  this.addHeaderFooterGroup(HeaderFooterType.FOOTER, footerWrapperGroup);
@@ -16836,59 +16885,6 @@ var HeaderWrapper = class {
16836
16885
  }
16837
16886
  };
16838
16887
  //#endregion
16839
- //#region src/file/media/media.ts
16840
- /**
16841
- * Manages embedded media (images) in a document.
16842
- *
16843
- * Media stores all images referenced in the document and provides
16844
- * access to their data for packaging into the DOCX file. Each image
16845
- * is stored with a unique key for retrieval.
16846
- *
16847
- * @example
16848
- * ```typescript
16849
- * const media = new Media();
16850
- * media.addImage("image1", {
16851
- * type: "png",
16852
- * fileName: "image1.png",
16853
- * transformation: {
16854
- * pixels: { x: 200, y: 100 },
16855
- * emus: { x: 1828800, y: 914400 }
16856
- * },
16857
- * data: imageBuffer
16858
- * });
16859
- * const allImages = media.Array;
16860
- * ```
16861
- */
16862
- var Media = class {
16863
- constructor() {
16864
- _defineProperty(this, "map", void 0);
16865
- this.map = /* @__PURE__ */ new Map();
16866
- }
16867
- /**
16868
- * Adds an image to the media collection.
16869
- *
16870
- * @param key - Unique identifier for this image
16871
- * @param mediaData - Complete image data including file name, transformation, and raw data
16872
- */
16873
- addImage(key, mediaData) {
16874
- this.map.set(key, mediaData);
16875
- }
16876
- /**
16877
- * Gets all images as an array.
16878
- *
16879
- * @returns Read-only array of all media data in the collection
16880
- */
16881
- get Array() {
16882
- return [...this.map.values()];
16883
- }
16884
- };
16885
- //#endregion
16886
- //#region src/file/media/data.ts
16887
- /**
16888
- * @ignore
16889
- */
16890
- const WORKAROUND2 = "";
16891
- //#endregion
16892
16888
  //#region src/file/numbering/level.ts
16893
16889
  /**
16894
16890
  * Numbering level definitions module for WordprocessingML documents.
package/dist/index.umd.js CHANGED
@@ -7452,23 +7452,97 @@
7452
7452
  }
7453
7453
  };
7454
7454
  //#endregion
7455
- //#region src/file/paragraph/run/image-run.ts
7456
- const createImageData = (data, transformation, key, srcRect) => ({
7457
- data,
7458
- fileName: key,
7459
- srcRect,
7460
- transformation: {
7455
+ //#region src/file/media/media.ts
7456
+ /**
7457
+ * Converts user-facing transformation options (pixels) to internal
7458
+ * transformation data (pixels + EMUs).
7459
+ *
7460
+ * @param options - User-facing transformation in pixels
7461
+ * @returns Internal transformation data with both pixel and EMU values
7462
+ */
7463
+ const createTransformation = (options) => {
7464
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7465
+ return {
7461
7466
  emus: {
7462
- x: Math.round(transformation.width * 9525),
7463
- y: Math.round(transformation.height * 9525)
7467
+ x: Math.round(options.width * 9525),
7468
+ y: Math.round(options.height * 9525)
7469
+ },
7470
+ flip: options.flip,
7471
+ offset: {
7472
+ emus: {
7473
+ x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7474
+ y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7475
+ },
7476
+ pixels: {
7477
+ x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7478
+ y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7479
+ }
7464
7480
  },
7465
- flip: transformation.flip,
7466
7481
  pixels: {
7467
- x: Math.round(transformation.width),
7468
- y: Math.round(transformation.height)
7482
+ x: Math.round(options.width),
7483
+ y: Math.round(options.height)
7469
7484
  },
7470
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7485
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7486
+ };
7487
+ };
7488
+ /**
7489
+ * Manages embedded media (images) in a document.
7490
+ *
7491
+ * Media stores all images referenced in the document and provides
7492
+ * access to their data for packaging into the DOCX file. Each image
7493
+ * is stored with a unique key for retrieval.
7494
+ *
7495
+ * @example
7496
+ * ```typescript
7497
+ * const media = new Media();
7498
+ * media.addImage("image1", {
7499
+ * type: "png",
7500
+ * fileName: "image1.png",
7501
+ * transformation: {
7502
+ * pixels: { x: 200, y: 100 },
7503
+ * emus: { x: 1828800, y: 914400 }
7504
+ * },
7505
+ * data: imageBuffer
7506
+ * });
7507
+ * const allImages = media.Array;
7508
+ * ```
7509
+ */
7510
+ var Media = class {
7511
+ constructor() {
7512
+ _defineProperty(this, "map", void 0);
7513
+ this.map = /* @__PURE__ */ new Map();
7471
7514
  }
7515
+ /**
7516
+ * Adds an image to the media collection.
7517
+ *
7518
+ * @param key - Unique identifier for this image
7519
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7520
+ */
7521
+ addImage(key, mediaData) {
7522
+ this.map.set(key, mediaData);
7523
+ }
7524
+ /**
7525
+ * Gets all images as an array.
7526
+ *
7527
+ * @returns Read-only array of all media data in the collection
7528
+ */
7529
+ get Array() {
7530
+ return [...this.map.values()];
7531
+ }
7532
+ };
7533
+ //#endregion
7534
+ //#region src/file/media/data.ts
7535
+ /**
7536
+ * @ignore
7537
+ */
7538
+ const WORKAROUND2 = "";
7539
+ //#endregion
7540
+ //#region src/file/paragraph/run/image-run.ts
7541
+ const createImageData = (data, transformation, key, srcRect) => ({
7542
+ data,
7543
+ fileName: key,
7544
+ srcRect,
7545
+ transformation: createTransformation(transformation)
7472
7546
  });
7473
7547
  /**
7474
7548
  * Represents an image in a WordprocessingML document.
@@ -7527,31 +7601,6 @@
7527
7601
  };
7528
7602
  //#endregion
7529
7603
  //#region src/file/paragraph/run/wps-shape-run.ts
7530
- const createTransformation = (options) => {
7531
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7532
- return {
7533
- emus: {
7534
- x: Math.round(options.width * 9525),
7535
- y: Math.round(options.height * 9525)
7536
- },
7537
- flip: options.flip,
7538
- offset: {
7539
- emus: {
7540
- x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7541
- y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7542
- },
7543
- pixels: {
7544
- x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7545
- y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7546
- }
7547
- },
7548
- pixels: {
7549
- x: Math.round(options.width),
7550
- y: Math.round(options.height)
7551
- },
7552
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7553
- };
7554
- };
7555
7604
  /**
7556
7605
  * @publicApi
7557
7606
  */
@@ -15353,23 +15402,23 @@
15353
15402
  * Default margin values for sections (in twips).
15354
15403
  *
15355
15404
  * Standard margins are 1 inch (1440 twips) on all sides.
15356
- * Header/footer margins are 0.5 inches (708 twips) from page edge.
15405
+ * Header/footer margins are from page edge.
15357
15406
  *
15358
15407
  * @property TOP - Top margin: 1440 twips (1 inch)
15359
- * @property RIGHT - Right margin: 1440 twips (1 inch)
15408
+ * @property RIGHT - Right margin: 1800 twips (1.25 inches)
15360
15409
  * @property BOTTOM - Bottom margin: 1440 twips (1 inch)
15361
- * @property LEFT - Left margin: 1440 twips (1 inch)
15362
- * @property HEADER - Header margin: 708 twips (0.5 inches)
15363
- * @property FOOTER - Footer margin: 708 twips (0.5 inches)
15410
+ * @property LEFT - Left margin: 1800 twips (1.25 inches)
15411
+ * @property HEADER - Header margin: 851 twips (0.59 inches)
15412
+ * @property FOOTER - Footer margin: 992 twips (0.69 inches)
15364
15413
  * @property GUTTER - Gutter margin: 0 twips
15365
15414
  */
15366
15415
  const sectionMarginDefaults = {
15367
15416
  TOP: 1440,
15368
- RIGHT: 1440,
15417
+ RIGHT: 1800,
15369
15418
  BOTTOM: 1440,
15370
- LEFT: 1440,
15371
- HEADER: 708,
15372
- FOOTER: 708,
15419
+ LEFT: 1800,
15420
+ HEADER: 851,
15421
+ FOOTER: 992,
15373
15422
  GUTTER: 0
15374
15423
  };
15375
15424
  /**
@@ -15436,7 +15485,7 @@
15436
15485
  * ```
15437
15486
  */
15438
15487
  var SectionProperties = class extends XmlComponent {
15439
- constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 360, charSpace, type: gridType } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15488
+ constructor({ page: { size: { width = sectionPageSizeDefaults.WIDTH, height = sectionPageSizeDefaults.HEIGHT, orientation = sectionPageSizeDefaults.ORIENTATION } = {}, margin: { top = sectionMarginDefaults.TOP, right = sectionMarginDefaults.RIGHT, bottom = sectionMarginDefaults.BOTTOM, left = sectionMarginDefaults.LEFT, header = sectionMarginDefaults.HEADER, footer = sectionMarginDefaults.FOOTER, gutter = sectionMarginDefaults.GUTTER } = {}, pageNumbers = {}, borders, textDirection } = {}, grid: { linePitch = 312, charSpace = 0, type: gridType = "lines" } = {}, headerWrapperGroup = {}, footerWrapperGroup = {}, lineNumbers, titlePage, verticalAlign, column, type, revision, noEndnote, bidi, rtlGutter, paperSrc, footnotePr, endnotePr } = {}) {
15440
15489
  super("w:sectPr");
15441
15490
  this.addHeaderFooterGroup(HeaderFooterType.HEADER, headerWrapperGroup);
15442
15491
  this.addHeaderFooterGroup(HeaderFooterType.FOOTER, footerWrapperGroup);
@@ -16866,59 +16915,6 @@
16866
16915
  }
16867
16916
  };
16868
16917
  //#endregion
16869
- //#region src/file/media/media.ts
16870
- /**
16871
- * Manages embedded media (images) in a document.
16872
- *
16873
- * Media stores all images referenced in the document and provides
16874
- * access to their data for packaging into the DOCX file. Each image
16875
- * is stored with a unique key for retrieval.
16876
- *
16877
- * @example
16878
- * ```typescript
16879
- * const media = new Media();
16880
- * media.addImage("image1", {
16881
- * type: "png",
16882
- * fileName: "image1.png",
16883
- * transformation: {
16884
- * pixels: { x: 200, y: 100 },
16885
- * emus: { x: 1828800, y: 914400 }
16886
- * },
16887
- * data: imageBuffer
16888
- * });
16889
- * const allImages = media.Array;
16890
- * ```
16891
- */
16892
- var Media = class {
16893
- constructor() {
16894
- _defineProperty(this, "map", void 0);
16895
- this.map = /* @__PURE__ */ new Map();
16896
- }
16897
- /**
16898
- * Adds an image to the media collection.
16899
- *
16900
- * @param key - Unique identifier for this image
16901
- * @param mediaData - Complete image data including file name, transformation, and raw data
16902
- */
16903
- addImage(key, mediaData) {
16904
- this.map.set(key, mediaData);
16905
- }
16906
- /**
16907
- * Gets all images as an array.
16908
- *
16909
- * @returns Read-only array of all media data in the collection
16910
- */
16911
- get Array() {
16912
- return [...this.map.values()];
16913
- }
16914
- };
16915
- //#endregion
16916
- //#region src/file/media/data.ts
16917
- /**
16918
- * @ignore
16919
- */
16920
- const WORKAROUND2 = "";
16921
- //#endregion
16922
16918
  //#region src/file/numbering/level.ts
16923
16919
  /**
16924
16920
  * Numbering level definitions module for WordprocessingML documents.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-plus",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
5
5
  "keywords": [
6
6
  "clippy",