@qrcommunication/gigapdf-lib 0.116.0 → 0.118.0

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.ts CHANGED
@@ -162,7 +162,21 @@ declare class GigaPdfEngine {
162
162
  */
163
163
  helveticaWidth(size: number, text: string): number;
164
164
  txtToPdf(text: string): Uint8Array;
165
- htmlToPdf(html: string): Uint8Array;
165
+ /**
166
+ * HTML → PDF. With no `options` this is the fixed US-Letter portrait / 0.5in
167
+ * path (byte-for-byte unchanged). Pass `options` — a named/explicit page size,
168
+ * `landscape`, per-side `margin`, or a running `header`/`footer` — to configure
169
+ * the page; that route delegates to {@link GigaPdfEngine.htmlRenderWith}, the
170
+ * canonical rich path (use it directly for embedded fonts, host-fetched images,
171
+ * or `{{page}}`/`{{pages}}` tokens). External `<img>`/font URLs are omitted here
172
+ * (no host fetch); supply them through `htmlRenderWith`.
173
+ *
174
+ * ```ts
175
+ * const a4 = giga.htmlToPdf(html); // 612×792
176
+ * const land = giga.htmlToPdf(html, { pageSize: "A4", landscape: true });
177
+ * ```
178
+ */
179
+ htmlToPdf(html: string, options?: HtmlToPdfOptions): Uint8Array;
166
180
  rtfToPdf(rtf: string): Uint8Array;
167
181
  /** Office (DOCX/ODT/PPTX/XLSX/ODS) → PDF, auto-detected. Empty array if unrecognized. */
168
182
  officeToPdf(office: Uint8Array): Uint8Array;
@@ -487,6 +501,12 @@ interface HtmlRenderOptions {
487
501
  pageWidth?: number;
488
502
  /** Explicit page height in points (default 792). Ignored if `pageSize` is set. */
489
503
  pageHeight?: number;
504
+ /**
505
+ * Orient the resolved page in landscape (width ≥ height): swaps the width and
506
+ * height of the portrait size resolved from `pageSize` / `pageWidth` /
507
+ * `pageHeight`. No effect on an already-landscape size.
508
+ */
509
+ landscape?: boolean;
490
510
  /** Uniform margin (points) or per-side margins. Default 36pt (0.5in). */
491
511
  margin?: number | HtmlMargins;
492
512
  /** Running header HTML painted in the top margin (`{{page}}` / `{{pages}}` tokens). */
@@ -507,6 +527,13 @@ interface HtmlRenderOptions {
507
527
  */
508
528
  resources?: HtmlResource[];
509
529
  }
530
+ /**
531
+ * Page-setup options for {@link GigaPdfEngine.htmlToPdf} — the page-shaping
532
+ * subset of {@link HtmlRenderOptions} (size, `landscape`, margins, running
533
+ * header/footer). For embedded fonts, host-fetched images, or page-number
534
+ * tokens, call {@link GigaPdfEngine.htmlRenderWith} directly.
535
+ */
536
+ type HtmlToPdfOptions = Pick<HtmlRenderOptions, "pageSize" | "pageWidth" | "pageHeight" | "landscape" | "margin" | "header" | "footer">;
510
537
  interface FontInfo {
511
538
  family: string;
512
539
  category: string;
@@ -660,6 +687,24 @@ interface GigaCharStyle {
660
687
  /** RGB `0..=1`, or `null` for default black. */
661
688
  color: [number, number, number] | null;
662
689
  valign: 'baseline' | 'super' | 'sub';
690
+ /**
691
+ * All-capitals display transform (`w:caps`, PPTX `cap="all"`). The run text
692
+ * keeps its original casing — render with `text-transform:uppercase`.
693
+ * Additive (omitted when off); present since 0.117.0.
694
+ */
695
+ caps?: boolean;
696
+ /** Small-capitals variant (`w:smallCaps`, PPTX `cap="small"`) — render with
697
+ * `font-variant:small-caps`. Additive (omitted when off). */
698
+ small_caps?: boolean;
699
+ /** Double strike-through (`w:dstrike`); `strike` stays set alongside as the
700
+ * single-line fallback. Additive (omitted when off). */
701
+ dstrike?: boolean;
702
+ /** Baseline shift in points (positive raises; `w:position` ÷ 2). Additive. */
703
+ baseline_shift_pt?: number;
704
+ /** Horizontal character scaling in percent (`w:w`; 100 = normal). Additive. */
705
+ char_scale_pct?: number;
706
+ /** Kerning threshold in points (`w:kern` ÷ 2). Additive. */
707
+ kern_min_pt?: number;
663
708
  }
664
709
  /** An axis-aligned placement box, lower-left `(x,y)` + size, in PDF points. */
665
710
  interface GigaRect {
@@ -668,19 +713,35 @@ interface GigaRect {
668
713
  w: number;
669
714
  h: number;
670
715
  }
671
- /** A hyperlink destination (tagged; mirror of `model::LinkTarget`). */
716
+ /**
717
+ * A hyperlink destination (tagged; mirror of `model::LinkTarget`).
718
+ *
719
+ * Beyond the external `url` and the resolved zero-based `page` jump:
720
+ * `anchor` is a **named in-document anchor** (a DOCX bookmark that did not —
721
+ * or could not yet — resolve to a page), and `other` a raw action summary a
722
+ * PDF link carried that has no URL/page equivalent (`"GoToR:report.pdf"`,
723
+ * `"Named:NextPage"`, `"Launch:app.exe"`). Both present since 0.117.0.
724
+ */
672
725
  type GigaLinkTarget = {
673
726
  t: 'url';
674
727
  v: string;
675
728
  } | {
676
729
  t: 'page';
677
730
  v: number;
731
+ } | {
732
+ t: 'anchor';
733
+ v: string;
734
+ } | {
735
+ t: 'other';
736
+ v: string;
678
737
  };
679
738
  /**
680
739
  * An inline (within-paragraph) node, tagged by `t` (mirror of `model::Inline`).
681
740
  * `run` carries the styled text + its `source_index` back to the editable
682
741
  * content-stream operator; `br` is a hard line break; `image` an inline image;
683
- * `link` wraps children with a destination.
742
+ * `link` wraps children with a destination; `footnoteRef` anchors a
743
+ * foot-/endnote whose body lives in `GigaDocument.footnotes` (the superscript
744
+ * call marker is the note's 1-based position there — present since 0.117.0).
684
745
  */
685
746
  type GigaInline = {
686
747
  t: 'run';
@@ -694,6 +755,9 @@ type GigaInline = {
694
755
  t: 'link';
695
756
  href: GigaLinkTarget;
696
757
  children: GigaInline[];
758
+ } | {
759
+ t: 'footnoteRef';
760
+ id: string;
697
761
  };
698
762
  /** A styled span of text (mirror of `model::InlineRun`). */
699
763
  interface GigaInlineRun {
@@ -727,6 +791,65 @@ interface GigaParagraphStyle {
727
791
  t: 'points';
728
792
  v: number;
729
793
  };
794
+ /**
795
+ * Base writing direction. Omitted = unspecified (reads as `ltr`). Set from
796
+ * DOCX `w:bidi` / PPTX `a:pPr@rtl` / ODF `writing-mode:rl-tb` / RTF
797
+ * `\rtlpar`, and by reconstruction's Unicode strong-script heuristic
798
+ * (>60 % Hebrew/Arabic strong letters). Present since 0.117.0.
799
+ */
800
+ direction?: 'ltr' | 'rtl';
801
+ /**
802
+ * Wrap-vs-deliberate classification of the paragraph's line breaks
803
+ * (reconstruction only): entry `k` is `true` when the break between line
804
+ * `k` and `k + 1` is **soft** (a word-wrap consequence an exporter may
805
+ * re-flow across) and `false` for a deliberate short line (verse, address).
806
+ * Omitted/empty = not analysed. The `{t:'br'}` inlines themselves are
807
+ * unchanged. Present since 0.117.0.
808
+ */
809
+ soft_breaks?: boolean[];
810
+ /**
811
+ * Force a page break before this paragraph (DOCX `w:pageBreakBefore`, ODF
812
+ * `fo:break-before="page"`) — the authored intent, kept alongside the
813
+ * structural page split so exporters re-emit the property. Additive
814
+ * (omitted when off).
815
+ */
816
+ page_break_before?: boolean;
817
+ }
818
+ /**
819
+ * One side of a paragraph or table-cell border: width in points, a line-style
820
+ * keyword (`solid`/`dashed`/`dotted`/`double`), and an RGB colour (mirror of
821
+ * `model::ParaBorder`).
822
+ */
823
+ interface GigaParaBorder {
824
+ width_pt: number;
825
+ style: string;
826
+ color: [number, number, number];
827
+ }
828
+ /**
829
+ * A linear gradient fill (mirror of `model::Gradient`): ordered colour stops
830
+ * (position `0..=1`, RGB, opacity) plus the axis angle in degrees clockwise
831
+ * from +X (`0` = left→right, `90` = top→bottom — the DrawingML convention).
832
+ * Carried alongside the flat RGB fill, which stays the first stop's colour.
833
+ */
834
+ interface GigaGradient {
835
+ stops: {
836
+ pos: number;
837
+ color: [number, number, number];
838
+ alpha: number;
839
+ }[];
840
+ angle_deg: number;
841
+ }
842
+ /**
843
+ * An outer drop shadow (mirror of `model::Shadow`): offset in points
844
+ * (+X right, +Y down — the CSS `box-shadow` convention), Gaussian blur
845
+ * radius, RGB colour and opacity.
846
+ */
847
+ interface GigaShadow {
848
+ dx_pt: number;
849
+ dy_pt: number;
850
+ blur_pt: number;
851
+ color: [number, number, number];
852
+ alpha: number;
730
853
  }
731
854
  /** A paragraph: its own style, an optional named-style ref, and its inline runs. */
732
855
  interface GigaParagraph {
@@ -760,11 +883,37 @@ interface GigaListItem {
760
883
  blocks: GigaBlock[];
761
884
  level: number;
762
885
  }
886
+ /**
887
+ * One depth's marker style in a multi-level list (mirror of
888
+ * `model::ListLevelStyle`): the marker (its tag is the number format —
889
+ * `bullet` ⇒ an unordered depth), the ordinal suffix (omitted ⇒ `"."`), and
890
+ * the depth's first ordinal (omitted ⇒ 1). Present since 0.117.0.
891
+ */
892
+ interface GigaListLevelStyle {
893
+ marker: GigaListMarker;
894
+ /** Ordinal suffix for an ordered depth (e.g. `")"`); omitted ⇒ `"."`. */
895
+ suffix?: string;
896
+ /** First ordinal of the depth; omitted ⇒ 1. */
897
+ start?: number;
898
+ }
763
899
  /** An ordered or unordered list (mirror of `model::List`). */
764
900
  interface GigaList {
765
901
  ordered: boolean;
766
902
  marker: GigaListMarker;
767
903
  items: GigaListItem[];
904
+ /** Start number for ordered lists; omitted ⇒ 1. */
905
+ start?: number;
906
+ /** Ordinal suffix (`"."`/`")"`); omitted ⇒ the conventional `"."`. */
907
+ marker_suffix?: string;
908
+ /**
909
+ * Per-depth marker table indexed by `GigaListItem.level` (entry 0 = the
910
+ * outermost depth), from DOCX `numbering.xml` multi-level definitions.
911
+ * Omitted/empty ⇒ the table-wide `marker`/`marker_suffix` apply to every
912
+ * depth. Present since 0.117.0.
913
+ */
914
+ levels?: GigaListLevelStyle[];
915
+ /** Ordinal prefix — the `"("` of a `"(a)"` marker. Omitted ⇒ none. */
916
+ marker_prefix?: string;
768
917
  }
769
918
  /** A table cell: block content, span, and optional RGB shading (`model::Cell`). */
770
919
  interface GigaTableCell {
@@ -773,6 +922,18 @@ interface GigaTableCell {
773
922
  row_span: number;
774
923
  /** RGB `0..=1` background, or `null` for no shading. */
775
924
  shading: [number, number, number] | null;
925
+ /**
926
+ * Per-cell borders `[top, right, bottom, left]` (same shape as the
927
+ * paragraph borders). Omitted = no per-cell regime: the table-wide
928
+ * `GigaTable.border` applies. When present, a `null` side draws nothing
929
+ * (an explicit "no line here"). Present since 0.117.0.
930
+ */
931
+ borders?: [
932
+ GigaParaBorder | null,
933
+ GigaParaBorder | null,
934
+ GigaParaBorder | null,
935
+ GigaParaBorder | null
936
+ ];
776
937
  }
777
938
  /** A table row: its cells and an optional fixed height in points (`model::Row`). */
778
939
  interface GigaTableRow {
@@ -804,6 +965,18 @@ interface GigaImageRef {
804
965
  */
805
966
  resource: string | number;
806
967
  alt: string | null;
968
+ /**
969
+ * Authored display size `[width, height]` in points (DOCX inline
970
+ * `wp:extent`) — a flow image re-exports at its real size instead of a
971
+ * default extent. Omitted when the source carried none. Present since 0.117.0.
972
+ */
973
+ size_pt?: [number, number];
974
+ /**
975
+ * Source-rectangle crop `[left, top, right, bottom]` inset fractions
976
+ * (`0..=1` each; DrawingML `a:srcRect`). Omitted = uncropped. Present
977
+ * since 0.117.0.
978
+ */
979
+ crop?: [number, number, number, number];
807
980
  }
808
981
  /** A single vector path segment (tagged; mirror of `content::vector::PathSeg`). */
809
982
  type GigaPathSeg = {
@@ -834,6 +1007,13 @@ interface GigaShape {
834
1007
  stroke: [number, number, number] | null;
835
1008
  stroke_width: number;
836
1009
  dash: number[];
1010
+ /**
1011
+ * Full gradient fill (PPTX/ODP `gradFill`). Primes over the flat `fill`,
1012
+ * which keeps the first stop's colour as the fallback. Present since 0.117.0.
1013
+ */
1014
+ fill_gradient?: GigaGradient;
1015
+ /** Outer drop shadow (`a:outerShdw`). Present since 0.117.0. */
1016
+ shadow?: GigaShadow;
837
1017
  }
838
1018
  /** A free-floating text box holding a list of blocks (mirror of `model::TextBox`). */
839
1019
  interface GigaTextBox {
@@ -846,6 +1026,27 @@ interface GigaSheetCell {
846
1026
  /** RGB `0..=1` cell fill, or `null` for none. */
847
1027
  fill: [number, number, number] | null;
848
1028
  style: GigaCharStyle;
1029
+ /**
1030
+ * Text rotation in signed degrees CCW (`+45` slants up, `-45` down; XLSX
1031
+ * `alignment@textRotation`). Omitted = horizontal. Present since 0.117.0.
1032
+ */
1033
+ rotation_deg?: number;
1034
+ /**
1035
+ * Diagonal border line(s): which diagonal(s) draw (`up` = bottom-left →
1036
+ * top-right, `down` = top-left → bottom-right) and the line width/colour.
1037
+ * Present since 0.117.0.
1038
+ */
1039
+ diagonal?: {
1040
+ up: boolean;
1041
+ down: boolean;
1042
+ border: GigaBorderStyle;
1043
+ };
1044
+ /**
1045
+ * Base reading direction of the cell's text (XLSX `alignment@readingOrder`
1046
+ * `2`⇒`rtl`/`1`⇒`ltr`, ODS `style:writing-mode`). Omitted = unspecified
1047
+ * (reads left-to-right). Additive.
1048
+ */
1049
+ direction?: 'ltr' | 'rtl';
849
1050
  }
850
1051
  /** One spreadsheet row (mirror of `model::SheetRow`). */
851
1052
  interface GigaSheetRow {
@@ -864,6 +1065,12 @@ interface GigaSheet {
864
1065
  rows: GigaSheetRow[];
865
1066
  merges: GigaMergeRange[];
866
1067
  col_widths: number[];
1068
+ /**
1069
+ * Frozen panes `[rows, cols]`: leading rows/columns pinned while the rest
1070
+ * scrolls (XLSX `<pane state="frozen">`). Omitted = no freeze. Present
1071
+ * since 0.117.0.
1072
+ */
1073
+ freeze?: [number, number];
867
1074
  }
868
1075
  /** A block of spreadsheet content: one or more sheets (mirror of `model::SheetBlock`). */
869
1076
  interface GigaSheetBlock {
@@ -895,6 +1102,17 @@ interface GigaPageGeometry {
895
1102
  bottom: number;
896
1103
  left: number;
897
1104
  };
1105
+ /** Text columns on the page (1 = single-column body text). */
1106
+ column_count?: number;
1107
+ /** Gutter between text columns in points (DOCX `w:cols@w:space`). Omitted =
1108
+ * the suite default. Present since 0.117.0. */
1109
+ column_gap_pt?: number;
1110
+ /** Individual column widths in points (a `w:equalWidth="0"` layout).
1111
+ * Omitted = equal-width columns. Present since 0.117.0. */
1112
+ column_widths_pt?: number[];
1113
+ /** Vertical separator rule between columns (`w:cols@w:sep`). Present since
1114
+ * 0.117.0. */
1115
+ column_separator?: boolean;
898
1116
  }
899
1117
  /** A single slide (mirror of `model::Slide`). */
900
1118
  interface GigaSlide {
@@ -902,6 +1120,13 @@ interface GigaSlide {
902
1120
  shapes: GigaBlock[];
903
1121
  placeholders: GigaPlaceholder[];
904
1122
  notes: GigaBlock[] | null;
1123
+ /** Full-slide background fill (RGB `0..=1`), or `null`/omitted = white. */
1124
+ background?: [number, number, number] | null;
1125
+ /**
1126
+ * Full-slide gradient background; primes over the flat `background`
1127
+ * (which keeps the first stop's colour). Present since 0.117.0.
1128
+ */
1129
+ background_gradient?: GigaGradient;
905
1130
  }
906
1131
  /** A block of presentation content: an ordered list of slides (`model::SlideBlock`). */
907
1132
  interface GigaSlideBlock {
@@ -974,6 +1199,19 @@ interface GigaSection {
974
1199
  geometry: GigaPageGeometry;
975
1200
  header: GigaBlock[] | null;
976
1201
  footer: GigaBlock[] | null;
1202
+ /**
1203
+ * Distinct first-page header/footer (DOCX `w:titlePg`). Omitted = the
1204
+ * default applies everywhere; `[]` = a *blank* first-page variant (Word's
1205
+ * "different first page" with an empty header). Present since 0.117.0.
1206
+ */
1207
+ header_first?: GigaBlock[];
1208
+ footer_first?: GigaBlock[];
1209
+ /**
1210
+ * Distinct even-page header/footer (DOCX `w:evenAndOddHeaders`). Same
1211
+ * omitted/`[]` semantics as the first-page variants. Present since 0.117.0.
1212
+ */
1213
+ header_even?: GigaBlock[];
1214
+ footer_even?: GigaBlock[];
977
1215
  pages: GigaPage[];
978
1216
  }
979
1217
  /**
@@ -996,6 +1234,16 @@ interface GigaOutlineNode {
996
1234
  * beyond what a host typically edits (`styles`, `resources`) are carried
997
1235
  * opaquely so a round-trip preserves them.
998
1236
  */
1237
+ /**
1238
+ * A foot-/endnote (mirror of `model::Footnote`): its document-unique `id`
1239
+ * (matched by the in-flow `{ t: 'footnoteRef' }` anchors) and its body as a
1240
+ * full block list. The display ordinal is the note's 1-based position in
1241
+ * `GigaDocument.footnotes`. Present since 0.117.0.
1242
+ */
1243
+ interface GigaFootnote {
1244
+ id: string;
1245
+ blocks: GigaBlock[];
1246
+ }
999
1247
  interface GigaDocument {
1000
1248
  v: number;
1001
1249
  meta: {
@@ -1010,6 +1258,12 @@ interface GigaDocument {
1010
1258
  /** Bookmark / chapter hierarchy (empty when the source has none). */
1011
1259
  outline: GigaOutlineNode[];
1012
1260
  resources: unknown;
1261
+ /**
1262
+ * Foot-/endnotes anchored in the body by `{ t: 'footnoteRef' }` inlines
1263
+ * (DOCX `footnotes.xml`/`endnotes.xml`, RTF `{\footnote …}`). Omitted when
1264
+ * the document carries none. Present since 0.117.0.
1265
+ */
1266
+ footnotes?: GigaFootnote[];
1013
1267
  }
1014
1268
  /**
1015
1269
  * A positional block address `[section, page, index]` (all zero-based) — the
@@ -3545,4 +3799,4 @@ declare class GigaPdfDoc {
3545
3799
  regenerateFieldAppearance(name: string): boolean;
3546
3800
  }
3547
3801
 
3548
- export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type EmbeddedFontV2, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HFAlign, type HFItem, type HFZone, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type RunningHeaderFooter, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type TextSegment, type VectorPathInfo, type ViewerPreferences, type WidgetPlacement, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
3802
+ export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type EmbeddedFontV2, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaFootnote, type GigaGeneric, type GigaGradient, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListLevelStyle, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaBorder, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShadow, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HFAlign, type HFItem, type HFZone, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type HtmlToPdfOptions, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type RunningHeaderFooter, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type TextSegment, type VectorPathInfo, type ViewerPreferences, type WidgetPlacement, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
package/dist/index.js CHANGED
@@ -314,7 +314,24 @@ var GigaPdfEngine = class _GigaPdfEngine {
314
314
  txtToPdf(text) {
315
315
  return this._withStr(text, (p, l) => this._buffer((o) => this.ex.gp_txt_to_pdf(p, l, o)));
316
316
  }
317
- htmlToPdf(html) {
317
+ /**
318
+ * HTML → PDF. With no `options` this is the fixed US-Letter portrait / 0.5in
319
+ * path (byte-for-byte unchanged). Pass `options` — a named/explicit page size,
320
+ * `landscape`, per-side `margin`, or a running `header`/`footer` — to configure
321
+ * the page; that route delegates to {@link GigaPdfEngine.htmlRenderWith}, the
322
+ * canonical rich path (use it directly for embedded fonts, host-fetched images,
323
+ * or `{{page}}`/`{{pages}}` tokens). External `<img>`/font URLs are omitted here
324
+ * (no host fetch); supply them through `htmlRenderWith`.
325
+ *
326
+ * ```ts
327
+ * const a4 = giga.htmlToPdf(html); // 612×792
328
+ * const land = giga.htmlToPdf(html, { pageSize: "A4", landscape: true });
329
+ * ```
330
+ */
331
+ htmlToPdf(html, options) {
332
+ if (options && Object.keys(options).length > 0) {
333
+ return this.htmlRenderWith(html, [], options);
334
+ }
318
335
  return this._withStr(html, (p, l) => this._buffer((o) => this.ex.gp_html_to_pdf(p, l, o)));
319
336
  }
320
337
  rtfToPdf(rtf) {
@@ -664,6 +681,9 @@ var GigaPdfEngine = class _GigaPdfEngine {
664
681
  pw = sz.w;
665
682
  ph = sz.h;
666
683
  }
684
+ if (options.landscape && ph > pw) {
685
+ [pw, ph] = [ph, pw];
686
+ }
667
687
  const m = options.margin ?? 36;
668
688
  const mg = typeof m === "number" ? { top: m, right: m, bottom: m, left: m } : { top: m.top ?? 36, right: m.right ?? 36, bottom: m.bottom ?? 36, left: m.left ?? 36 };
669
689
  const headerOffset = options.headerOffset ?? 18;