html2pdf-accessible 0.0.0-stage → 0.1.5

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.
Files changed (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -2
  3. package/THIRD_PARTY_NOTICES.md +15 -0
  4. package/deps/canvaskit-pdf/CHROMIUM-LICENSE +27 -0
  5. package/deps/canvaskit-pdf/LICENSE +29 -0
  6. package/deps/canvaskit-pdf/README.md +35 -0
  7. package/deps/canvaskit-pdf/THIRD_PARTY_LICENSES.txt +2152 -0
  8. package/deps/canvaskit-pdf/bin/canvaskit.js +215 -0
  9. package/deps/canvaskit-pdf/chromium-license-source.json +5 -0
  10. package/deps/canvaskit-pdf/package.json +22 -0
  11. package/deps/canvaskit-pdf/pdf_bindings.cpp +179 -0
  12. package/deps/canvaskit-pdf/provenance.json +37 -0
  13. package/deps/canvaskit-pdf/types/google-types.d.ts +4948 -0
  14. package/deps/canvaskit-pdf/types/index.d.ts +48 -0
  15. package/lib/html2pdf-accessible.cjs.js +3 -0
  16. package/lib/html2pdf-accessible.cjs.js.LICENSE.txt +14 -0
  17. package/lib/html2pdf-accessible.cjs.js.map +1 -0
  18. package/lib/html2pdf-accessible.esm.mjs +3 -0
  19. package/lib/html2pdf-accessible.esm.mjs.LICENSE.txt +14 -0
  20. package/lib/html2pdf-accessible.esm.mjs.map +1 -0
  21. package/lib/html2pdf-accessible.js +3 -0
  22. package/lib/html2pdf-accessible.js.LICENSE.txt +14 -0
  23. package/lib/html2pdf-accessible.js.map +1 -0
  24. package/lib/html2pdf-accessible.min.js +17 -0
  25. package/lib/html2pdf-accessible.min.js.map +1 -0
  26. package/lib/types/core/bitwise.d.ts +1 -0
  27. package/lib/types/core/cache-storage.d.ts +27 -0
  28. package/lib/types/core/context.d.ts +17 -0
  29. package/lib/types/core/debugger.d.ts +8 -0
  30. package/lib/types/core/features.d.ts +12 -0
  31. package/lib/types/core/logger.d.ts +18 -0
  32. package/lib/types/core/util.d.ts +1 -0
  33. package/lib/types/css/IPropertyDescriptor.d.ts +36 -0
  34. package/lib/types/css/ITypeDescriptor.d.ts +6 -0
  35. package/lib/types/css/index.d.ts +134 -0
  36. package/lib/types/css/layout/bounds.d.ts +14 -0
  37. package/lib/types/css/layout/text.d.ts +13 -0
  38. package/lib/types/css/property-descriptors/background-clip.d.ts +8 -0
  39. package/lib/types/css/property-descriptors/background-color.d.ts +2 -0
  40. package/lib/types/css/property-descriptors/background-image.d.ts +3 -0
  41. package/lib/types/css/property-descriptors/background-origin.d.ts +8 -0
  42. package/lib/types/css/property-descriptors/background-position.d.ts +5 -0
  43. package/lib/types/css/property-descriptors/background-repeat.d.ts +9 -0
  44. package/lib/types/css/property-descriptors/background-size.d.ts +11 -0
  45. package/lib/types/css/property-descriptors/border-color.d.ts +5 -0
  46. package/lib/types/css/property-descriptors/border-radius.d.ts +7 -0
  47. package/lib/types/css/property-descriptors/border-style.d.ts +12 -0
  48. package/lib/types/css/property-descriptors/border-width.d.ts +5 -0
  49. package/lib/types/css/property-descriptors/box-shadow.d.ts +14 -0
  50. package/lib/types/css/property-descriptors/color.d.ts +2 -0
  51. package/lib/types/css/property-descriptors/content.d.ts +4 -0
  52. package/lib/types/css/property-descriptors/counter-increment.d.ts +7 -0
  53. package/lib/types/css/property-descriptors/counter-reset.d.ts +7 -0
  54. package/lib/types/css/property-descriptors/direction.d.ts +6 -0
  55. package/lib/types/css/property-descriptors/display.d.ts +35 -0
  56. package/lib/types/css/property-descriptors/duration.d.ts +2 -0
  57. package/lib/types/css/property-descriptors/float.d.ts +9 -0
  58. package/lib/types/css/property-descriptors/font-family.d.ts +4 -0
  59. package/lib/types/css/property-descriptors/font-size.d.ts +2 -0
  60. package/lib/types/css/property-descriptors/font-style.d.ts +7 -0
  61. package/lib/types/css/property-descriptors/font-variant.d.ts +2 -0
  62. package/lib/types/css/property-descriptors/font-weight.d.ts +2 -0
  63. package/lib/types/css/property-descriptors/letter-spacing.d.ts +2 -0
  64. package/lib/types/css/property-descriptors/line-break.d.ts +6 -0
  65. package/lib/types/css/property-descriptors/line-height.d.ts +4 -0
  66. package/lib/types/css/property-descriptors/list-style-image.d.ts +3 -0
  67. package/lib/types/css/property-descriptors/list-style-position.d.ts +6 -0
  68. package/lib/types/css/property-descriptors/list-style-type.d.ts +58 -0
  69. package/lib/types/css/property-descriptors/margin.d.ts +5 -0
  70. package/lib/types/css/property-descriptors/object-fit.d.ts +10 -0
  71. package/lib/types/css/property-descriptors/opacity.d.ts +2 -0
  72. package/lib/types/css/property-descriptors/overflow-wrap.d.ts +6 -0
  73. package/lib/types/css/property-descriptors/overflow.d.ts +9 -0
  74. package/lib/types/css/property-descriptors/padding.d.ts +5 -0
  75. package/lib/types/css/property-descriptors/paint-order.d.ts +8 -0
  76. package/lib/types/css/property-descriptors/position.d.ts +9 -0
  77. package/lib/types/css/property-descriptors/quotes.d.ts +8 -0
  78. package/lib/types/css/property-descriptors/text-align.d.ts +7 -0
  79. package/lib/types/css/property-descriptors/text-decoration-color.d.ts +2 -0
  80. package/lib/types/css/property-descriptors/text-decoration-line.d.ts +10 -0
  81. package/lib/types/css/property-descriptors/text-shadow.d.ts +12 -0
  82. package/lib/types/css/property-descriptors/text-transform.d.ts +8 -0
  83. package/lib/types/css/property-descriptors/transform-origin.d.ts +4 -0
  84. package/lib/types/css/property-descriptors/transform.d.ts +4 -0
  85. package/lib/types/css/property-descriptors/visibility.d.ts +7 -0
  86. package/lib/types/css/property-descriptors/webkit-text-stroke-color.d.ts +2 -0
  87. package/lib/types/css/property-descriptors/webkit-text-stroke-width.d.ts +2 -0
  88. package/lib/types/css/property-descriptors/word-break.d.ts +7 -0
  89. package/lib/types/css/property-descriptors/z-index.d.ts +7 -0
  90. package/lib/types/css/syntax/parser.d.ts +34 -0
  91. package/lib/types/css/syntax/tokenizer.d.ts +94 -0
  92. package/lib/types/css/types/angle.d.ts +7 -0
  93. package/lib/types/css/types/color-calculation.d.ts +3 -0
  94. package/lib/types/css/types/color-spaces/a98.d.ts +39 -0
  95. package/lib/types/css/types/color-spaces/p3.d.ts +45 -0
  96. package/lib/types/css/types/color-spaces/pro-photo.d.ts +45 -0
  97. package/lib/types/css/types/color-spaces/rec2020.d.ts +45 -0
  98. package/lib/types/css/types/color-spaces/srgb.d.ts +38 -0
  99. package/lib/types/css/types/color-utilities.d.ts +108 -0
  100. package/lib/types/css/types/color.d.ts +8 -0
  101. package/lib/types/css/types/functions/-prefix-linear-gradient.d.ts +4 -0
  102. package/lib/types/css/types/functions/-prefix-radial-gradient.d.ts +4 -0
  103. package/lib/types/css/types/functions/-webkit-gradient.d.ts +4 -0
  104. package/lib/types/css/types/functions/counter.d.ts +10 -0
  105. package/lib/types/css/types/functions/gradient.d.ts +7 -0
  106. package/lib/types/css/types/functions/linear-gradient.d.ts +4 -0
  107. package/lib/types/css/types/functions/radial-gradient.d.ts +12 -0
  108. package/lib/types/css/types/image.d.ts +54 -0
  109. package/lib/types/css/types/index.d.ts +1 -0
  110. package/lib/types/css/types/length-percentage.d.ts +11 -0
  111. package/lib/types/css/types/length.d.ts +4 -0
  112. package/lib/types/css/types/time.d.ts +2 -0
  113. package/lib/types/dom/document-cloner.d.ts +45 -0
  114. package/lib/types/dom/element-container.d.ts +20 -0
  115. package/lib/types/dom/elements/li-element-container.d.ts +6 -0
  116. package/lib/types/dom/elements/ol-element-container.d.ts +7 -0
  117. package/lib/types/dom/elements/select-element-container.d.ts +6 -0
  118. package/lib/types/dom/elements/textarea-element-container.d.ts +6 -0
  119. package/lib/types/dom/node-parser.d.ts +25 -0
  120. package/lib/types/dom/replaced-elements/canvas-element-container.d.ts +8 -0
  121. package/lib/types/dom/replaced-elements/iframe-element-container.d.ts +11 -0
  122. package/lib/types/dom/replaced-elements/image-element-container.d.ts +8 -0
  123. package/lib/types/dom/replaced-elements/index.d.ts +4 -0
  124. package/lib/types/dom/replaced-elements/input-element-container.d.ts +12 -0
  125. package/lib/types/dom/replaced-elements/pseudo-elements.d.ts +0 -0
  126. package/lib/types/dom/replaced-elements/svg-element-container.d.ts +8 -0
  127. package/lib/types/dom/text-container.d.ts +8 -0
  128. package/lib/types/fonts/font-collection.d.ts +25 -0
  129. package/lib/types/fonts/font-enumeration.d.ts +5 -0
  130. package/lib/types/fonts/font-style-mapping.d.ts +3 -0
  131. package/lib/types/fonts/interfaces.d.ts +27 -0
  132. package/lib/types/html2canvas.d.ts +10 -0
  133. package/lib/types/index.d.ts +7 -0
  134. package/lib/types/invariant.d.ts +1 -0
  135. package/lib/types/pdf/bookmarks.d.ts +4 -0
  136. package/lib/types/pdf/canvaskit-loader.d.ts +56 -0
  137. package/lib/types/pdf/document-structure.d.ts +105 -0
  138. package/lib/types/pdf/dom-updates.d.ts +6 -0
  139. package/lib/types/pdf/finalize-structure.d.ts +6 -0
  140. package/lib/types/pdf/hidden-captions.d.ts +15 -0
  141. package/lib/types/pdf/html-page-break.d.ts +11 -0
  142. package/lib/types/pdf/link-annotations.d.ts +8 -0
  143. package/lib/types/pdf/link-uri.d.ts +2 -0
  144. package/lib/types/pdf/logical-structure.d.ts +3 -0
  145. package/lib/types/pdf/pdf-export.d.ts +29 -0
  146. package/lib/types/pdf/single-html-multi-page.d.ts +14 -0
  147. package/lib/types/pdf/table-headers.d.ts +6 -0
  148. package/lib/types/pdf/xmp-metadata.d.ts +5 -0
  149. package/lib/types/render/background.d.ts +16 -0
  150. package/lib/types/render/bezier-curve.d.ts +14 -0
  151. package/lib/types/render/border.d.ts +6 -0
  152. package/lib/types/render/bound-curves.d.ts +32 -0
  153. package/lib/types/render/box-sizing.d.ts +4 -0
  154. package/lib/types/render/canvas/canvas-renderer.d.ts +53 -0
  155. package/lib/types/render/canvas/foreignobject-renderer.d.ts +11 -0
  156. package/lib/types/render/effects.d.ts +38 -0
  157. package/lib/types/render/font-metrics.d.ts +11 -0
  158. package/lib/types/render/path.d.ts +13 -0
  159. package/lib/types/render/renderer.d.ts +7 -0
  160. package/lib/types/render/skia/skia-font.d.ts +27 -0
  161. package/lib/types/render/skia/skia-renderer.d.ts +69 -0
  162. package/lib/types/render/stacking-context.d.ts +24 -0
  163. package/lib/types/render/vector.d.ts +9 -0
  164. package/lib/wasm/canvaskit-pdf.wasm +0 -0
  165. package/node_modules/@html2pdf-skia/canvaskit-pdf/CHROMIUM-LICENSE +27 -0
  166. package/node_modules/@html2pdf-skia/canvaskit-pdf/LICENSE +29 -0
  167. package/node_modules/@html2pdf-skia/canvaskit-pdf/README.md +35 -0
  168. package/node_modules/@html2pdf-skia/canvaskit-pdf/THIRD_PARTY_LICENSES.txt +2152 -0
  169. package/node_modules/@html2pdf-skia/canvaskit-pdf/bin/canvaskit.js +215 -0
  170. package/node_modules/@html2pdf-skia/canvaskit-pdf/chromium-license-source.json +5 -0
  171. package/node_modules/@html2pdf-skia/canvaskit-pdf/package.json +22 -0
  172. package/node_modules/@html2pdf-skia/canvaskit-pdf/pdf_bindings.cpp +179 -0
  173. package/node_modules/@html2pdf-skia/canvaskit-pdf/provenance.json +37 -0
  174. package/node_modules/@html2pdf-skia/canvaskit-pdf/types/google-types.d.ts +4948 -0
  175. package/node_modules/@html2pdf-skia/canvaskit-pdf/types/index.d.ts +48 -0
  176. package/node_modules/@webgpu/types/LICENSE +26 -0
  177. package/node_modules/@webgpu/types/README.md +132 -0
  178. package/node_modules/@webgpu/types/dist/index.d.ts +3426 -0
  179. package/node_modules/@webgpu/types/package.json +23 -0
  180. package/package.json +125 -4
  181. package/scripts/canvaskit/build.cjs +74 -0
  182. package/scripts/canvaskit/build.py +143 -0
  183. package/scripts/canvaskit/verify.cjs +82 -0
@@ -0,0 +1,7 @@
1
+ import { CSSValue } from "../../syntax/parser";
2
+ import { CSSRadialGradientImage, GradientColorStop, GradientCorner, UnprocessedGradientColorStop } from "../image";
3
+ import { Context } from "../../../core/context";
4
+ export declare const parseColorStop: (context: Context, args: CSSValue[]) => UnprocessedGradientColorStop;
5
+ export declare const processColorStops: (stops: UnprocessedGradientColorStop[], lineLength: number) => GradientColorStop[];
6
+ export declare const calculateGradientDirection: (angle: number | GradientCorner, width: number, height: number) => [number, number, number, number, number];
7
+ export declare const calculateRadius: (gradient: CSSRadialGradientImage, x: number, y: number, width: number, height: number) => [number, number];
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from "../../syntax/parser";
2
+ import { CSSLinearGradientImage } from "../image";
3
+ import { Context } from "../../../core/context";
4
+ export declare const linearGradient: (context: Context, tokens: CSSValue[]) => CSSLinearGradientImage;
@@ -0,0 +1,12 @@
1
+ import { CSSValue } from "../../syntax/parser";
2
+ import { CSSRadialGradientImage } from "../image";
3
+ import { Context } from "../../../core/context";
4
+ export declare const CLOSEST_SIDE = "closest-side";
5
+ export declare const FARTHEST_SIDE = "farthest-side";
6
+ export declare const CLOSEST_CORNER = "closest-corner";
7
+ export declare const FARTHEST_CORNER = "farthest-corner";
8
+ export declare const CIRCLE = "circle";
9
+ export declare const ELLIPSE = "ellipse";
10
+ export declare const COVER = "cover";
11
+ export declare const CONTAIN = "contain";
12
+ export declare const radialGradient: (context: Context, tokens: CSSValue[]) => CSSRadialGradientImage;
@@ -0,0 +1,54 @@
1
+ import { CSSValue } from "../syntax/parser";
2
+ import { Color } from "./color";
3
+ import { ITypeDescriptor } from "../ITypeDescriptor";
4
+ import { LengthPercentage } from "./length-percentage";
5
+ export declare const enum CSSImageType {
6
+ URL = 0,
7
+ LINEAR_GRADIENT = 1,
8
+ RADIAL_GRADIENT = 2
9
+ }
10
+ export declare const isLinearGradient: (background: ICSSImage) => background is CSSLinearGradientImage;
11
+ export declare const isRadialGradient: (background: ICSSImage) => background is CSSRadialGradientImage;
12
+ export interface UnprocessedGradientColorStop {
13
+ color: Color;
14
+ stop: LengthPercentage | null;
15
+ }
16
+ export interface GradientColorStop {
17
+ color: Color;
18
+ stop: number;
19
+ }
20
+ export interface ICSSImage {
21
+ type: CSSImageType;
22
+ }
23
+ export interface CSSURLImage extends ICSSImage {
24
+ url: string;
25
+ type: CSSImageType.URL;
26
+ }
27
+ export type GradientCorner = [LengthPercentage, LengthPercentage];
28
+ interface ICSSGradientImage extends ICSSImage {
29
+ stops: UnprocessedGradientColorStop[];
30
+ }
31
+ export interface CSSLinearGradientImage extends ICSSGradientImage {
32
+ angle: number | GradientCorner;
33
+ type: CSSImageType.LINEAR_GRADIENT;
34
+ }
35
+ export declare const enum CSSRadialShape {
36
+ CIRCLE = 0,
37
+ ELLIPSE = 1
38
+ }
39
+ export declare const enum CSSRadialExtent {
40
+ CLOSEST_SIDE = 0,
41
+ FARTHEST_SIDE = 1,
42
+ CLOSEST_CORNER = 2,
43
+ FARTHEST_CORNER = 3
44
+ }
45
+ export type CSSRadialSize = CSSRadialExtent | LengthPercentage[];
46
+ export interface CSSRadialGradientImage extends ICSSGradientImage {
47
+ type: CSSImageType.RADIAL_GRADIENT;
48
+ shape: CSSRadialShape;
49
+ size: CSSRadialSize;
50
+ position: LengthPercentage[];
51
+ }
52
+ export declare const image: ITypeDescriptor<ICSSImage>;
53
+ export declare function isSupportedImage(value: CSSValue): boolean;
54
+ export {};
@@ -0,0 +1 @@
1
+ export type CSSTypes = "angle" | "color" | "image" | "length" | "length-percentage" | "time";
@@ -0,0 +1,11 @@
1
+ import { DimensionToken, NumberValueToken } from "../syntax/tokenizer";
2
+ import { CSSValue } from "../syntax/parser";
3
+ export type LengthPercentage = DimensionToken | NumberValueToken;
4
+ export type LengthPercentageTuple = [LengthPercentage] | [LengthPercentage, LengthPercentage];
5
+ export declare const isLengthPercentage: (token: CSSValue) => token is LengthPercentage;
6
+ export declare const parseLengthPercentageTuple: (tokens: LengthPercentage[]) => LengthPercentageTuple;
7
+ export declare const ZERO_LENGTH: NumberValueToken;
8
+ export declare const FIFTY_PERCENT: NumberValueToken;
9
+ export declare const HUNDRED_PERCENT: NumberValueToken;
10
+ export declare const getAbsoluteValueForTuple: (tuple: LengthPercentageTuple, width: number, height: number) => [number, number];
11
+ export declare const getAbsoluteValue: (token: LengthPercentage, parent: number) => number;
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from "../syntax/parser";
2
+ import { DimensionToken, NumberValueToken } from "../syntax/tokenizer";
3
+ export type Length = DimensionToken | NumberValueToken;
4
+ export declare const isLength: (token: CSSValue) => token is Length;
@@ -0,0 +1,2 @@
1
+ import { ITypeDescriptor } from "../ITypeDescriptor";
2
+ export declare const time: ITypeDescriptor<number>;
@@ -0,0 +1,45 @@
1
+ import { Bounds } from "../css/layout/bounds";
2
+ import { Context } from "../core/context";
3
+ export interface CloneOptions {
4
+ ignoreElements?: (element: Element) => boolean;
5
+ onclone?: (document: Document, element: HTMLElement) => void;
6
+ allowTaint?: boolean;
7
+ }
8
+ export interface WindowOptions {
9
+ scrollX: number;
10
+ scrollY: number;
11
+ windowWidth: number;
12
+ windowHeight: number;
13
+ }
14
+ export type CloneConfigurations = CloneOptions & {
15
+ inlineImages: boolean;
16
+ copyStyles: boolean;
17
+ };
18
+ export declare class DocumentCloner {
19
+ private readonly context;
20
+ private readonly options;
21
+ private readonly scrolledElements;
22
+ private readonly referenceElement;
23
+ clonedReferenceElement?: HTMLElement;
24
+ private readonly documentElement;
25
+ private readonly counters;
26
+ private quoteDepth;
27
+ constructor(context: Context, element: HTMLElement, options: CloneConfigurations);
28
+ toIFrame(ownerDocument: Document, windowSize: Bounds): Promise<HTMLIFrameElement>;
29
+ createElementClone<T extends HTMLElement | SVGElement>(node: T): HTMLElement | SVGElement;
30
+ createCustomElementClone(node: HTMLElement): HTMLElement;
31
+ createStyleClone(node: HTMLStyleElement): HTMLStyleElement;
32
+ createCanvasClone(canvas: HTMLCanvasElement): HTMLImageElement | HTMLCanvasElement;
33
+ createVideoClone(video: HTMLVideoElement): HTMLCanvasElement;
34
+ appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void;
35
+ cloneChildNodes(node: Element, clone: HTMLElement | SVGElement, copyStyles: boolean): void;
36
+ cloneNode(node: Node, copyStyles: boolean): Node;
37
+ resolvePseudoContent(node: Element, clone: Element, style: CSSStyleDeclaration, pseudoElt: PseudoElementType): HTMLElement | void;
38
+ static destroy(container: HTMLIFrameElement): boolean;
39
+ }
40
+ declare enum PseudoElementType {
41
+ BEFORE = 0,
42
+ AFTER = 1
43
+ }
44
+ export declare const copyCSSStyles: <T extends HTMLElement | SVGElement>(style: CSSStyleDeclaration, target: T) => T;
45
+ export {};
@@ -0,0 +1,20 @@
1
+ import { CSSParsedDeclaration } from "../css/index";
2
+ import { TextContainer } from "./text-container";
3
+ import { Bounds } from "../css/layout/bounds";
4
+ import { Context } from "../core/context";
5
+ export declare const enum FLAGS {
6
+ CREATES_STACKING_CONTEXT = 2,
7
+ CREATES_REAL_STACKING_CONTEXT = 4,
8
+ IS_LIST_OWNER = 8,
9
+ DEBUG_RENDER = 16
10
+ }
11
+ export declare class ElementContainer {
12
+ protected readonly context: Context;
13
+ readonly styles: CSSParsedDeclaration;
14
+ readonly textNodes: TextContainer[];
15
+ readonly elements: ElementContainer[];
16
+ bounds: Bounds;
17
+ flags: number;
18
+ readonly pdfTagNodeId?: number;
19
+ constructor(context: Context, element: Element);
20
+ }
@@ -0,0 +1,6 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class LIElementContainer extends ElementContainer {
4
+ readonly value: number;
5
+ constructor(context: Context, element: HTMLLIElement);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class OLElementContainer extends ElementContainer {
4
+ readonly start: number;
5
+ readonly reversed: boolean;
6
+ constructor(context: Context, element: HTMLOListElement);
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class SelectElementContainer extends ElementContainer {
4
+ readonly value: string;
5
+ constructor(context: Context, element: HTMLSelectElement);
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class TextareaElementContainer extends ElementContainer {
4
+ readonly value: string;
5
+ constructor(context: Context, element: HTMLTextAreaElement);
6
+ }
@@ -0,0 +1,25 @@
1
+ import { ElementContainer } from "./element-container";
2
+ import { Context } from "../core/context";
3
+ import { Color } from "../css/types/color";
4
+ export declare const parseTree: (context: Context, element: HTMLElement) => ElementContainer;
5
+ export declare const isTextNode: (node: Node) => node is Text;
6
+ export declare const isElementNode: (node: Node) => node is Element;
7
+ export declare const isHTMLElementNode: (node: Node) => node is HTMLElement;
8
+ export declare const isSVGElementNode: (element: Element) => element is SVGElement;
9
+ export declare const isLIElement: (node: Element) => node is HTMLLIElement;
10
+ export declare const isOLElement: (node: Element) => node is HTMLOListElement;
11
+ export declare const isInputElement: (node: Element) => node is HTMLInputElement;
12
+ export declare const isHTMLElement: (node: Element) => node is HTMLHtmlElement;
13
+ export declare const isSVGElement: (node: Element) => node is SVGSVGElement;
14
+ export declare const isBodyElement: (node: Element) => node is HTMLBodyElement;
15
+ export declare const isCanvasElement: (node: Element) => node is HTMLCanvasElement;
16
+ export declare const isVideoElement: (node: Element) => node is HTMLVideoElement;
17
+ export declare const isImageElement: (node: Element) => node is HTMLImageElement;
18
+ export declare const isIFrameElement: (node: Element) => node is HTMLIFrameElement;
19
+ export declare const isStyleElement: (node: Element) => node is HTMLStyleElement;
20
+ export declare const isScriptElement: (node: Element) => node is HTMLScriptElement;
21
+ export declare const isTextareaElement: (node: Element) => node is HTMLTextAreaElement;
22
+ export declare const isSelectElement: (node: Element) => node is HTMLSelectElement;
23
+ export declare const isSlotElement: (node: Element) => node is HTMLSlotElement;
24
+ export declare const isCustomElement: (node: Element) => node is HTMLElement;
25
+ export declare const parseBackgroundColor: (context: Context, element: HTMLElement, backgroundColorOverride?: string | null) => Color;
@@ -0,0 +1,8 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class CanvasElementContainer extends ElementContainer {
4
+ canvas: HTMLCanvasElement;
5
+ intrinsicWidth: number;
6
+ intrinsicHeight: number;
7
+ constructor(context: Context, canvas: HTMLCanvasElement);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Color } from "../../css/types/color";
3
+ import { Context } from "../../core/context";
4
+ export declare class IFrameElementContainer extends ElementContainer {
5
+ src: string;
6
+ width: number;
7
+ height: number;
8
+ tree?: ElementContainer;
9
+ backgroundColor: Color;
10
+ constructor(context: Context, iframe: HTMLIFrameElement);
11
+ }
@@ -0,0 +1,8 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class ImageElementContainer extends ElementContainer {
4
+ src: string;
5
+ intrinsicWidth: number;
6
+ intrinsicHeight: number;
7
+ constructor(context: Context, img: HTMLImageElement);
8
+ }
@@ -0,0 +1,4 @@
1
+ import { CanvasElementContainer } from "./canvas-element-container";
2
+ import { ImageElementContainer } from "./image-element-container";
3
+ import { SVGElementContainer } from "./svg-element-container";
4
+ export type ReplacedElementContainer = CanvasElementContainer | ImageElementContainer | SVGElementContainer;
@@ -0,0 +1,12 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare const CHECKBOX = "checkbox";
4
+ export declare const RADIO = "radio";
5
+ export declare const PASSWORD = "password";
6
+ export declare const INPUT_COLOR = 707406591;
7
+ export declare class InputElementContainer extends ElementContainer {
8
+ readonly type: string;
9
+ readonly checked: boolean;
10
+ readonly value: string;
11
+ constructor(context: Context, input: HTMLInputElement);
12
+ }
@@ -0,0 +1,8 @@
1
+ import { ElementContainer } from "../element-container";
2
+ import { Context } from "../../core/context";
3
+ export declare class SVGElementContainer extends ElementContainer {
4
+ svg: string;
5
+ intrinsicWidth: number;
6
+ intrinsicHeight: number;
7
+ constructor(context: Context, img: SVGSVGElement);
8
+ }
@@ -0,0 +1,8 @@
1
+ import { CSSParsedDeclaration } from "../css/index";
2
+ import { TextBounds } from "../css/layout/text";
3
+ import { Context } from "../core/context";
4
+ export declare class TextContainer {
5
+ text: string;
6
+ textBounds: TextBounds[];
7
+ constructor(context: Context, node: Text, styles: CSSParsedDeclaration);
8
+ }
@@ -0,0 +1,25 @@
1
+ import { CanvasKit, Font, Typeface, TypefaceFontProvider } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { FontFamilyClass, FontStylePojo, IFontCollection, IFontProperties, IFontStyle, UnicodeCharacterBucket } from "./interfaces";
3
+ export declare class SkiaFontCollection implements IFontCollection {
4
+ canvasKit: CanvasKit;
5
+ fontMgr: TypefaceFontProvider;
6
+ private defaultFonts;
7
+ private fallbackFonts;
8
+ private families;
9
+ private fonts;
10
+ private fontsCache;
11
+ readonly emptyFont: Font;
12
+ constructor(canvasKit: CanvasKit);
13
+ addFont(buffer: ArrayBuffer, family: string, fontStyle?: IFontStyle, url?: string, descriptors?: FontFaceDescriptors): void;
14
+ setDefaultFonts(fontFamilyClass: FontFamilyClass, families: string[]): void;
15
+ getFontData(families: string[], weight: number): ArrayBuffer | undefined;
16
+ setFallbackFonts(unicodeCharacterBucket: UnicodeCharacterBucket, families: string[]): void;
17
+ getMissingFonts(element: HTMLElement): IFontProperties[];
18
+ getMissingGlyphsCategories(element: HTMLElement): UnicodeCharacterBucket[];
19
+ getFallbackFontTypeface(text: string, fontStyle: FontStylePojo): Typeface | null;
20
+ getFallbackFontFamilies(familyClasses: FontFamilyClass[]): string[];
21
+ addFontsToDocument(cloneDocument: Document): Promise<void>;
22
+ getFont(typeface: Typeface, fontSize: number): Font;
23
+ clearResources(): void;
24
+ }
25
+ export declare function createFontCollection(canvasKit: CanvasKit): IFontCollection;
@@ -0,0 +1,5 @@
1
+ import { FontMgr } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { IFontProperties, UnicodeCharacterBucket } from "./interfaces";
3
+ export declare function enumerateFonts(elements: HTMLElement[]): IFontProperties[];
4
+ export declare function enumerateMissingGlyphs(fontMgr: FontMgr, elements: HTMLElement[]): UnicodeCharacterBucket[];
5
+ export declare function getUnicodeCharacterBucket(text: string): UnicodeCharacterBucket;
@@ -0,0 +1,3 @@
1
+ import { IFontProperties, FontSlant, FontStylePojo } from "./interfaces";
2
+ export declare function toSkiaFontSlant(slant: FontSlant): number;
3
+ export declare function toSkiaFontStyle(fontStyle: IFontProperties): [string[], FontStylePojo];
@@ -0,0 +1,27 @@
1
+ export type FontWidth = "normal" | "narrow" | "wide";
2
+ export type FontSlant = "normal" | "italic" | "oblique";
3
+ export type FontFamilyClass = "serif" | "sans-serif" | "monospace" | "cursive" | "fantasy" | "fangsong";
4
+ export type UnicodeCharacterBucket = "cjk" | "emoji" | "symbol" | "unicode";
5
+ export interface IFontStyle {
6
+ fontWeight?: number;
7
+ fontWidth?: FontWidth;
8
+ fontSlant?: FontSlant;
9
+ }
10
+ export type IFontProperties = IFontStyle & {
11
+ families: string[];
12
+ };
13
+ export type FontFamilyKey = FontFamilyClass | UnicodeCharacterBucket;
14
+ export interface IFontCollection {
15
+ getFontData?(families: string[], weight: number): ArrayBuffer | undefined;
16
+ addFont(buffer: ArrayBuffer, family: string, fontStyle?: IFontStyle, url?: string, descriptors?: FontFaceDescriptors): void;
17
+ setDefaultFonts(fontFamilyClass: FontFamilyClass, families: string[]): void;
18
+ setFallbackFonts(unicodeCharacterBucket: UnicodeCharacterBucket, families: string[]): void;
19
+ getMissingFonts(element: HTMLElement): IFontProperties[];
20
+ getMissingGlyphsCategories(element: HTMLElement, fontStyle: IFontStyle): string[];
21
+ clearResources(): void;
22
+ }
23
+ export interface FontStylePojo {
24
+ weight?: number;
25
+ width?: number;
26
+ slant?: number;
27
+ }
@@ -0,0 +1,10 @@
1
+ import { CloneOptions, WindowOptions } from "./dom/document-cloner";
2
+ import { RenderOptions } from "./render/canvas/canvas-renderer";
3
+ import { ContextOptions } from "./core/context";
4
+ export type Options = CloneOptions & WindowOptions & RenderOptions & ContextOptions & {
5
+ backgroundColor: string | null;
6
+ foreignObjectRendering: boolean;
7
+ removeContainer?: boolean;
8
+ };
9
+ declare const html2canvas: (element: HTMLElement, options?: Partial<Options>) => Promise<HTMLCanvasElement>;
10
+ export default html2canvas;
@@ -0,0 +1,7 @@
1
+ export { exportHTMLDocumentToPdf } from "./pdf/single-html-multi-page";
2
+ export type { ExportPdfOptions } from "./pdf/single-html-multi-page";
3
+ export { loadCanvasKit, preloadCanvasKit } from "./pdf/canvaskit-loader";
4
+ export type { CanvasKitLoadOptions } from "./pdf/canvaskit-loader";
5
+ export { isCanvasKitLoaded, getCanvasKitInstance, } from "./pdf/canvaskit-loader";
6
+ export * from "./fonts/interfaces";
7
+ export { createFontCollection } from "./fonts/font-collection";
@@ -0,0 +1 @@
1
+ export declare const invariant: (assertion: boolean, error: string) => void;
@@ -0,0 +1,4 @@
1
+ import { PDFDocument } from "pdf-lib";
2
+ import { PDFStructureTag } from "./document-structure";
3
+ /** Follow the heading hierarchy and use the renderer's actual page positions. */
4
+ export declare function addBookmarks(pdf: PDFDocument, headings: PDFStructureTag[]): void;
@@ -0,0 +1,56 @@
1
+ import { CanvasKit } from "@html2pdf-skia/canvaskit-pdf";
2
+ /**
3
+ * Configuration options for CanvasKit loading
4
+ */
5
+ export interface CanvasKitLoadOptions {
6
+ /**
7
+ * Custom WASM binary URL. If not provided, uses the bundled WASM file.
8
+ */
9
+ wasmBinaryUrl: string;
10
+ /**
11
+ * Timeout in milliseconds for loading CanvasKit (default: 30000)
12
+ */
13
+ timeout?: number;
14
+ /**
15
+ * Whether to log loading progress
16
+ */
17
+ verbose?: boolean;
18
+ }
19
+ /**
20
+ * Loads CanvasKit WASM module and returns the CanvasKit instance
21
+ *
22
+ * @param options - Configuration options for loading CanvasKit
23
+ * @returns Promise that resolves to the CanvasKit instance
24
+ */
25
+ export declare const loadCanvasKit: (options: CanvasKitLoadOptions) => Promise<CanvasKit>;
26
+ /**
27
+ * Checks if CanvasKit is already loaded
28
+ *
29
+ * @returns True if CanvasKit is loaded, false otherwise
30
+ */
31
+ export declare const isCanvasKitLoaded: () => boolean;
32
+ /**
33
+ * Gets the cached CanvasKit instance without loading
34
+ *
35
+ * @returns The cached CanvasKit instance or null if not loaded
36
+ */
37
+ export declare const getCanvasKitInstance: () => CanvasKit | null;
38
+ /**
39
+ * Preloads CanvasKit WASM in the background
40
+ * This can be called early in the application lifecycle to improve performance
41
+ *
42
+ * @param options - Configuration options for loading CanvasKit
43
+ * @returns Promise that resolves when CanvasKit is loaded
44
+ */
45
+ export declare const preloadCanvasKit: (options: CanvasKitLoadOptions) => Promise<void>;
46
+ /**
47
+ * Resets the CanvasKit loader state
48
+ * This is mainly useful for testing or when you need to reload CanvasKit
49
+ */
50
+ export declare const resetCanvasKitLoader: () => void;
51
+ /**
52
+ * Utility function to check if CanvasKit is supported in the current environment
53
+ *
54
+ * @returns True if CanvasKit is likely to be supported
55
+ */
56
+ export declare const isCanvasKitSupported: () => boolean;
@@ -0,0 +1,105 @@
1
+ import { PDFTag } from "@html2pdf-skia/canvaskit-pdf";
2
+ export interface PDFStructureTag extends PDFTag {
3
+ children?: PDFStructureTag[];
4
+ elementIdentifier?: string;
5
+ headerIdentifiers?: string[];
6
+ bookmarkTitle?: string;
7
+ linkUri?: string;
8
+ linkText?: string;
9
+ linkDestinationIdentifier?: string;
10
+ linkToPageTop?: boolean;
11
+ isLinkDestination?: boolean;
12
+ hiddenCaption?: {
13
+ text: string;
14
+ families: string[];
15
+ weight: number;
16
+ };
17
+ renderedBounds?: {
18
+ pageIndex: number;
19
+ rect: [number, number, number, number];
20
+ }[];
21
+ }
22
+ export declare const STRUCTURE_MARKER_OWNER = "html2pdf-skia";
23
+ export declare const STRUCTURE_MARKER_NAME = "NodeId";
24
+ export declare const PREDEFINED_TAG_IDS: {
25
+ readonly Nothing: 0;
26
+ readonly OtherArtifact: -1;
27
+ readonly PaginationArtifact: -2;
28
+ readonly PaginationHeaderArtifact: -3;
29
+ readonly PaginationFooterArtifact: -4;
30
+ readonly PaginationWatermarkArtifact: -5;
31
+ readonly LayoutArtifact: -6;
32
+ readonly PageArtifact: -7;
33
+ readonly BackgroundArtifact: -8;
34
+ };
35
+ export declare const PDF_STRUCTURE_TYPES: {
36
+ readonly Document: "Document";
37
+ readonly Part: "Part";
38
+ readonly Art: "Art";
39
+ readonly Sect: "Sect";
40
+ readonly Div: "Div";
41
+ readonly P: "P";
42
+ readonly H1: "H1";
43
+ readonly H2: "H2";
44
+ readonly H3: "H3";
45
+ readonly H4: "H4";
46
+ readonly H5: "H5";
47
+ readonly H6: "H6";
48
+ readonly BlockQuote: "BlockQuote";
49
+ readonly Caption: "Caption";
50
+ readonly TOC: "TOC";
51
+ readonly TOCI: "TOCI";
52
+ readonly Index: "Index";
53
+ readonly Span: "Span";
54
+ readonly Quote: "Quote";
55
+ readonly Note: "Note";
56
+ readonly Reference: "Reference";
57
+ readonly BibEntry: "BibEntry";
58
+ readonly Code: "Code";
59
+ readonly Link: "Link";
60
+ readonly Annot: "Annot";
61
+ readonly L: "L";
62
+ readonly LI: "LI";
63
+ readonly Lbl: "Lbl";
64
+ readonly LBody: "LBody";
65
+ readonly Table: "Table";
66
+ readonly TR: "TR";
67
+ readonly TH: "TH";
68
+ readonly TD: "TD";
69
+ readonly THead: "THead";
70
+ readonly TBody: "TBody";
71
+ readonly TFoot: "TFoot";
72
+ readonly Figure: "Figure";
73
+ readonly Formula: "Formula";
74
+ readonly Form: "Form";
75
+ readonly NonStruct: "NonStruct";
76
+ readonly Artifact: "Artifact";
77
+ };
78
+ export declare const PDF_TAG_ATTRIBUTE = "data-x-pdf-tag-id";
79
+ /**
80
+ * Generate document structure from HTML tree
81
+ */
82
+ export declare function generateDocumentStructure(htmlElement: Element | Element[]): {
83
+ structure: PDFTag;
84
+ tagIdMap: Map<Element, number>;
85
+ };
86
+ /**
87
+ * Apply PDF structure to existing HTML document
88
+ */
89
+ export declare function applyPDFStructureToDocument(document: Document): {
90
+ structure: PDFTag;
91
+ tagIdMap: Map<Element, number>;
92
+ };
93
+ /**
94
+ * Get PDF tag for specific HTML element
95
+ */
96
+ export declare function getPDFTagForElement(element: Element): number | undefined;
97
+ export declare function getPDFTagForElementFromMap(element: Element, tagIdMap: Map<Element, number>): number | undefined;
98
+ /**
99
+ * Serialize PDF structure to JSON for debugging
100
+ */
101
+ export declare function serializePDFStructure(structure: PDFTag): string;
102
+ /**
103
+ * Validate PDF structure integrity
104
+ */
105
+ export declare function validatePDFStructure(structure: PDFTag): boolean;
@@ -0,0 +1,6 @@
1
+ export declare const HIDE_PREVIOUS_PAGE_ITEM_CLASS = "hide-previous-page-item";
2
+ export declare const HIDE_NEXT_PAGE_ITEM_CLASS = "hide-next-page-item";
3
+ export declare function appendPageStyles(document: Document): void;
4
+ export declare function clearPageStyles(document: Document): void;
5
+ export declare function clearHidePreviousPageItems(document: Document): void;
6
+ export declare function clearHideNextPageItems(document: Document): void;
@@ -0,0 +1,6 @@
1
+ import { PDFTag } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { IFontCollection } from "../fonts/interfaces";
3
+ /** Bridge the missing ID/Headers operations in Google SkPDF.
4
+ * Also restore clipped captions as invisible, embedded-font text.
5
+ */
6
+ export declare function finalizePDFStructure(bytes: Uint8Array, root: PDFTag, fontCollection?: IFontCollection): Promise<Uint8Array>;
@@ -0,0 +1,15 @@
1
+ import { PDFDict, PDFDocument, PDFRef } from "pdf-lib";
2
+ import { IFontCollection } from "../fonts/interfaces";
3
+ import { PDFStructureTag } from "./document-structure";
4
+ /** Replace only Skia's empty text object in this caption's existing MCID.
5
+ * Graphics and text state are isolated so subsequent visible text is unchanged.
6
+ */
7
+ export declare function fillEmptyCaption(content: string, mcid: number, font: string, encodedText: string, y: number): string;
8
+ /** Keep visually clipped table captions readable, using invisible text (Tr 3).
9
+ * Reuse the original MCID, structure node and ParentTree entry. Embed the supplied
10
+ * font with a Unicode map; do not substitute alternate text for an empty node.
11
+ */
12
+ export declare function restoreHiddenCaptions(pdf: PDFDocument, nodes: Map<number, {
13
+ node: PDFDict;
14
+ ref: PDFRef;
15
+ }>, tags: Map<number, PDFStructureTag>, fonts?: IFontCollection): Promise<void>;
@@ -0,0 +1,11 @@
1
+ export declare class HtmlPageBreak {
2
+ private document;
3
+ private pageHeight;
4
+ private pageItems;
5
+ constructor(document: Document, pageHeight: number);
6
+ processPage(): HTMLElement | null;
7
+ protected shouldTreatAsSingleElement(element: HTMLElement): boolean;
8
+ protected shouldCheckForOverlap(element: HTMLElement): boolean;
9
+ protected shouldRepeatOnEveryPage(element: HTMLElement): boolean;
10
+ postProcess(): void;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { PDFDict, PDFDocument, PDFRef } from "pdf-lib";
2
+ import { PDFStructureTag } from "./document-structure";
3
+ /** Link text, annotation, OBJR and ParentTree must describe the same action. */
4
+ export declare function addLinkAnnotations(pdf: PDFDocument, tree: PDFDict, links: {
5
+ tag: PDFStructureTag;
6
+ node: PDFDict;
7
+ ref: PDFRef;
8
+ }[], tags: Map<number, PDFStructureTag>): void;
@@ -0,0 +1,2 @@
1
+ /** Only web URLs may be emitted as external PDF URI actions. */
2
+ export declare function safeExternalLinkUri(value: string): string | undefined;
@@ -0,0 +1,3 @@
1
+ import { PDFDocument } from "pdf-lib";
2
+ /** Repair inline text directly inside grouping elements without changing MCIDs. */
3
+ export declare function normalizeLogicalStructure(pdf: PDFDocument): void;