@qrcommunication/gigapdf-lib 0.115.0 → 0.117.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 {
@@ -792,9 +953,30 @@ interface GigaTable {
792
953
  }
793
954
  /** A reference to an image blob in the document's resource table (`model::ImageRef`). */
794
955
  interface GigaImageRef {
795
- /** Content-hash key into `GigaDocument.resources.images`. */
796
- resource: number;
956
+ /**
957
+ * Content-hash key into `GigaDocument.resources.images`.
958
+ *
959
+ * A decimal string: the underlying id is a full 64-bit hash, which does not
960
+ * survive `JSON.parse` as a JavaScript number (precision is lost past 2^53,
961
+ * silently orphaning the reference from its resource — every image was
962
+ * dropped from `toModel()` → `modelTo*` round-trips). The engine emits it as
963
+ * a string and accepts either form (`string` canonically, legacy `number`
964
+ * for hand-built models with small ids).
965
+ */
966
+ resource: string | number;
797
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];
798
980
  }
799
981
  /** A single vector path segment (tagged; mirror of `content::vector::PathSeg`). */
800
982
  type GigaPathSeg = {
@@ -825,6 +1007,13 @@ interface GigaShape {
825
1007
  stroke: [number, number, number] | null;
826
1008
  stroke_width: number;
827
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;
828
1017
  }
829
1018
  /** A free-floating text box holding a list of blocks (mirror of `model::TextBox`). */
830
1019
  interface GigaTextBox {
@@ -837,6 +1026,21 @@ interface GigaSheetCell {
837
1026
  /** RGB `0..=1` cell fill, or `null` for none. */
838
1027
  fill: [number, number, number] | null;
839
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
+ };
840
1044
  }
841
1045
  /** One spreadsheet row (mirror of `model::SheetRow`). */
842
1046
  interface GigaSheetRow {
@@ -855,6 +1059,12 @@ interface GigaSheet {
855
1059
  rows: GigaSheetRow[];
856
1060
  merges: GigaMergeRange[];
857
1061
  col_widths: number[];
1062
+ /**
1063
+ * Frozen panes `[rows, cols]`: leading rows/columns pinned while the rest
1064
+ * scrolls (XLSX `<pane state="frozen">`). Omitted = no freeze. Present
1065
+ * since 0.117.0.
1066
+ */
1067
+ freeze?: [number, number];
858
1068
  }
859
1069
  /** A block of spreadsheet content: one or more sheets (mirror of `model::SheetBlock`). */
860
1070
  interface GigaSheetBlock {
@@ -886,6 +1096,17 @@ interface GigaPageGeometry {
886
1096
  bottom: number;
887
1097
  left: number;
888
1098
  };
1099
+ /** Text columns on the page (1 = single-column body text). */
1100
+ column_count?: number;
1101
+ /** Gutter between text columns in points (DOCX `w:cols@w:space`). Omitted =
1102
+ * the suite default. Present since 0.117.0. */
1103
+ column_gap_pt?: number;
1104
+ /** Individual column widths in points (a `w:equalWidth="0"` layout).
1105
+ * Omitted = equal-width columns. Present since 0.117.0. */
1106
+ column_widths_pt?: number[];
1107
+ /** Vertical separator rule between columns (`w:cols@w:sep`). Present since
1108
+ * 0.117.0. */
1109
+ column_separator?: boolean;
889
1110
  }
890
1111
  /** A single slide (mirror of `model::Slide`). */
891
1112
  interface GigaSlide {
@@ -893,6 +1114,13 @@ interface GigaSlide {
893
1114
  shapes: GigaBlock[];
894
1115
  placeholders: GigaPlaceholder[];
895
1116
  notes: GigaBlock[] | null;
1117
+ /** Full-slide background fill (RGB `0..=1`), or `null`/omitted = white. */
1118
+ background?: [number, number, number] | null;
1119
+ /**
1120
+ * Full-slide gradient background; primes over the flat `background`
1121
+ * (which keeps the first stop's colour). Present since 0.117.0.
1122
+ */
1123
+ background_gradient?: GigaGradient;
896
1124
  }
897
1125
  /** A block of presentation content: an ordered list of slides (`model::SlideBlock`). */
898
1126
  interface GigaSlideBlock {
@@ -965,6 +1193,19 @@ interface GigaSection {
965
1193
  geometry: GigaPageGeometry;
966
1194
  header: GigaBlock[] | null;
967
1195
  footer: GigaBlock[] | null;
1196
+ /**
1197
+ * Distinct first-page header/footer (DOCX `w:titlePg`). Omitted = the
1198
+ * default applies everywhere; `[]` = a *blank* first-page variant (Word's
1199
+ * "different first page" with an empty header). Present since 0.117.0.
1200
+ */
1201
+ header_first?: GigaBlock[];
1202
+ footer_first?: GigaBlock[];
1203
+ /**
1204
+ * Distinct even-page header/footer (DOCX `w:evenAndOddHeaders`). Same
1205
+ * omitted/`[]` semantics as the first-page variants. Present since 0.117.0.
1206
+ */
1207
+ header_even?: GigaBlock[];
1208
+ footer_even?: GigaBlock[];
968
1209
  pages: GigaPage[];
969
1210
  }
970
1211
  /**
@@ -987,6 +1228,16 @@ interface GigaOutlineNode {
987
1228
  * beyond what a host typically edits (`styles`, `resources`) are carried
988
1229
  * opaquely so a round-trip preserves them.
989
1230
  */
1231
+ /**
1232
+ * A foot-/endnote (mirror of `model::Footnote`): its document-unique `id`
1233
+ * (matched by the in-flow `{ t: 'footnoteRef' }` anchors) and its body as a
1234
+ * full block list. The display ordinal is the note's 1-based position in
1235
+ * `GigaDocument.footnotes`. Present since 0.117.0.
1236
+ */
1237
+ interface GigaFootnote {
1238
+ id: string;
1239
+ blocks: GigaBlock[];
1240
+ }
990
1241
  interface GigaDocument {
991
1242
  v: number;
992
1243
  meta: {
@@ -1001,6 +1252,12 @@ interface GigaDocument {
1001
1252
  /** Bookmark / chapter hierarchy (empty when the source has none). */
1002
1253
  outline: GigaOutlineNode[];
1003
1254
  resources: unknown;
1255
+ /**
1256
+ * Foot-/endnotes anchored in the body by `{ t: 'footnoteRef' }` inlines
1257
+ * (DOCX `footnotes.xml`/`endnotes.xml`, RTF `{\footnote …}`). Omitted when
1258
+ * the document carries none. Present since 0.117.0.
1259
+ */
1260
+ footnotes?: GigaFootnote[];
1004
1261
  }
1005
1262
  /**
1006
1263
  * A positional block address `[section, page, index]` (all zero-based) — the
@@ -3536,4 +3793,4 @@ declare class GigaPdfDoc {
3536
3793
  regenerateFieldAppearance(name: string): boolean;
3537
3794
  }
3538
3795
 
3539
- 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 };
3796
+ 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;