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,29 @@
1
+ import { CanvasKit, PDFTag } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { Context } from "../core/context";
3
+ import { IFontCollection } from "../fonts/interfaces";
4
+ export declare const defaultUserToPdfScale = 0.5;
5
+ export interface IPageSize {
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export interface IPdfInputProvider {
10
+ getDocumentTitle(): string;
11
+ getDocumentStructure(): PDFTag;
12
+ getNextPageElement(): Promise<HTMLElement | null>;
13
+ }
14
+ export interface IPdfOptions {
15
+ title: string;
16
+ author: string;
17
+ subject: string;
18
+ keywords: string;
19
+ creator: string;
20
+ producer: string;
21
+ language?: string;
22
+ userToPdfScale?: number;
23
+ pageSize: {
24
+ width: number;
25
+ height: number;
26
+ };
27
+ fontCollection?: IFontCollection;
28
+ }
29
+ export declare function exportToPdf(canvasKit: CanvasKit, context: Context, inputProvider: IPdfInputProvider, pdfOptions?: Partial<IPdfOptions>): Promise<Blob>;
@@ -0,0 +1,14 @@
1
+ import { PDFTag, CanvasKit } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { IPageSize, IPdfInputProvider, IPdfOptions } from "./pdf-export";
3
+ import { ContextOptions } from "../core/context";
4
+ export declare class SingleHtmlMultiPageProvider implements IPdfInputProvider {
5
+ private document;
6
+ private currentPageIndex;
7
+ private htmlPageBreak;
8
+ constructor(document: Document, pageSize: IPageSize);
9
+ getDocumentStructure(): PDFTag;
10
+ getNextPageElement(): Promise<HTMLElement | null>;
11
+ getDocumentTitle(): string;
12
+ }
13
+ export type ExportPdfOptions = ContextOptions & IPdfOptions;
14
+ export declare function exportHTMLDocumentToPdf(canvasKit: CanvasKit, document: Document, options: Partial<ExportPdfOptions>): Promise<Blob>;
@@ -0,0 +1,6 @@
1
+ /** Header relationships are resolved in the DOM, before pagination changes it. */
2
+ export interface TableHeaderInfo {
3
+ scope?: "Column" | "Row" | "Both";
4
+ headers: Element[];
5
+ }
6
+ export declare function resolveTableHeaders(root: Element): Map<Element, TableHeaderInfo>;
@@ -0,0 +1,5 @@
1
+ import { PDFDocument } from "pdf-lib";
2
+ /** Mirror the existing document information into a real XMP metadata stream.
3
+ * The PDF/UA-1 identifier states the target standard; validation is still needed.
4
+ */
5
+ export declare function addXmpMetadata(pdf: PDFDocument): void;
@@ -0,0 +1,16 @@
1
+ import { Bounds } from "../css/layout/bounds";
2
+ import { BACKGROUND_ORIGIN } from "../css/property-descriptors/background-origin";
3
+ import { ElementContainer } from "../dom/element-container";
4
+ import { BackgroundSizeInfo } from "../css/property-descriptors/background-size";
5
+ import { Vector } from "./vector";
6
+ import { BACKGROUND_REPEAT } from "../css/property-descriptors/background-repeat";
7
+ import { CSSValue } from "../css/syntax/parser";
8
+ import { Path } from "./path";
9
+ import { BACKGROUND_CLIP } from "../css/property-descriptors/background-clip";
10
+ export declare const calculateBackgroundPositioningArea: (backgroundOrigin: BACKGROUND_ORIGIN, element: ElementContainer) => Bounds;
11
+ export declare const calculateBackgroundPaintingArea: (backgroundClip: BACKGROUND_CLIP, element: ElementContainer) => Bounds;
12
+ export declare const calculateBackgroundRendering: (container: ElementContainer, index: number, intrinsicSize: [number | null, number | null, number | null]) => [Path[], number, number, number, number];
13
+ export declare const isAuto: (token: CSSValue) => boolean;
14
+ export declare const calculateBackgroundSize: (size: BackgroundSizeInfo[], [intrinsicWidth, intrinsicHeight, intrinsicProportion]: [number | null, number | null, number | null], bounds: Bounds) => [number, number];
15
+ export declare const getBackgroundValueForIndex: <T>(values: T[], index: number) => T;
16
+ export declare const calculateBackgroundRepeatPath: (repeat: BACKGROUND_REPEAT, [x, y]: [number, number], [width, height]: [number, number], backgroundPositioningArea: Bounds, backgroundPaintingArea: Bounds) => [Vector, Vector, Vector, Vector];
@@ -0,0 +1,14 @@
1
+ import { Vector } from "./vector";
2
+ import { IPath, PathType, Path } from "./path";
3
+ export declare class BezierCurve implements IPath {
4
+ type: PathType;
5
+ start: Vector;
6
+ startControl: Vector;
7
+ endControl: Vector;
8
+ end: Vector;
9
+ constructor(start: Vector, startControl: Vector, endControl: Vector, end: Vector);
10
+ subdivide(t: number, firstHalf: boolean): BezierCurve;
11
+ add(deltaX: number, deltaY: number): BezierCurve;
12
+ reverse(): BezierCurve;
13
+ }
14
+ export declare const isBezierCurve: (path: Path) => path is BezierCurve;
@@ -0,0 +1,6 @@
1
+ import { Path } from "./path";
2
+ import { BoundCurves } from "./bound-curves";
3
+ export declare const parsePathForBorder: (curves: BoundCurves, borderSide: number) => Path[];
4
+ export declare const parsePathForBorderDoubleOuter: (curves: BoundCurves, borderSide: number) => Path[];
5
+ export declare const parsePathForBorderDoubleInner: (curves: BoundCurves, borderSide: number) => Path[];
6
+ export declare const parsePathForBorderStroke: (curves: BoundCurves, borderSide: number) => Path[];
@@ -0,0 +1,32 @@
1
+ import { ElementContainer } from "../dom/element-container";
2
+ import { Path } from "./path";
3
+ export declare class BoundCurves {
4
+ readonly topLeftBorderDoubleOuterBox: Path;
5
+ readonly topRightBorderDoubleOuterBox: Path;
6
+ readonly bottomRightBorderDoubleOuterBox: Path;
7
+ readonly bottomLeftBorderDoubleOuterBox: Path;
8
+ readonly topLeftBorderDoubleInnerBox: Path;
9
+ readonly topRightBorderDoubleInnerBox: Path;
10
+ readonly bottomRightBorderDoubleInnerBox: Path;
11
+ readonly bottomLeftBorderDoubleInnerBox: Path;
12
+ readonly topLeftBorderStroke: Path;
13
+ readonly topRightBorderStroke: Path;
14
+ readonly bottomRightBorderStroke: Path;
15
+ readonly bottomLeftBorderStroke: Path;
16
+ readonly topLeftBorderBox: Path;
17
+ readonly topRightBorderBox: Path;
18
+ readonly bottomRightBorderBox: Path;
19
+ readonly bottomLeftBorderBox: Path;
20
+ readonly topLeftPaddingBox: Path;
21
+ readonly topRightPaddingBox: Path;
22
+ readonly bottomRightPaddingBox: Path;
23
+ readonly bottomLeftPaddingBox: Path;
24
+ readonly topLeftContentBox: Path;
25
+ readonly topRightContentBox: Path;
26
+ readonly bottomRightContentBox: Path;
27
+ readonly bottomLeftContentBox: Path;
28
+ constructor(element: ElementContainer);
29
+ }
30
+ export declare const calculateBorderBoxPath: (curves: BoundCurves) => Path[];
31
+ export declare const calculateContentBoxPath: (curves: BoundCurves) => Path[];
32
+ export declare const calculatePaddingBoxPath: (curves: BoundCurves) => Path[];
@@ -0,0 +1,4 @@
1
+ import { Bounds } from "../css/layout/bounds";
2
+ import { ElementContainer } from "../dom/element-container";
3
+ export declare const paddingBox: (element: ElementContainer) => Bounds;
4
+ export declare const contentBox: (element: ElementContainer) => Bounds;
@@ -0,0 +1,53 @@
1
+ import { ElementPaint, StackingContext } from "../stacking-context";
2
+ import { Color } from "../../css/types/color";
3
+ import { ElementContainer } from "../../dom/element-container";
4
+ import { BORDER_STYLE } from "../../css/property-descriptors/border-style";
5
+ import { CSSParsedDeclaration } from "../../css";
6
+ import { TextContainer } from "../../dom/text-container";
7
+ import { Path } from "../path";
8
+ import { BoundCurves } from "../bound-curves";
9
+ import { TextBounds } from "../../css/layout/text";
10
+ import { ReplacedElementContainer } from "../../dom/replaced-elements";
11
+ import { IElementEffect } from "../effects";
12
+ import { Renderer } from "../renderer";
13
+ import { Context } from "../../core/context";
14
+ export type RenderConfigurations = RenderOptions & {
15
+ backgroundColor: Color | null;
16
+ };
17
+ export interface RenderOptions {
18
+ scale: number;
19
+ canvas?: HTMLCanvasElement;
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ }
25
+ export declare class CanvasRenderer extends Renderer {
26
+ canvas: HTMLCanvasElement;
27
+ ctx: CanvasRenderingContext2D;
28
+ private readonly _activeEffects;
29
+ private readonly fontMetrics;
30
+ constructor(context: Context, options: RenderConfigurations);
31
+ applyEffects(effects: IElementEffect[]): void;
32
+ applyEffect(effect: IElementEffect): void;
33
+ popEffect(): void;
34
+ renderStack(stack: StackingContext): Promise<void>;
35
+ renderNode(paint: ElementPaint): Promise<void>;
36
+ renderTextWithLetterSpacing(text: TextBounds, letterSpacing: number, baseline: number): void;
37
+ private createFontStyle;
38
+ renderTextNode(text: TextContainer, styles: CSSParsedDeclaration): Promise<void>;
39
+ renderReplacedElement(container: ReplacedElementContainer, curves: BoundCurves, image: HTMLImageElement | HTMLCanvasElement): void;
40
+ renderNodeContent(paint: ElementPaint): Promise<void>;
41
+ renderStackContent(stack: StackingContext): Promise<void>;
42
+ mask(paths: Path[]): void;
43
+ path(paths: Path[]): void;
44
+ formatPath(paths: Path[]): void;
45
+ renderRepeat(path: Path[], pattern: CanvasPattern | CanvasGradient, offsetX: number, offsetY: number): void;
46
+ resizeImage(image: HTMLImageElement, width: number, height: number): HTMLCanvasElement | HTMLImageElement;
47
+ renderBackgroundImage(container: ElementContainer): Promise<void>;
48
+ renderSolidBorder(color: Color, side: number, curvePoints: BoundCurves): Promise<void>;
49
+ renderDoubleBorder(color: Color, width: number, side: number, curvePoints: BoundCurves): Promise<void>;
50
+ renderNodeBackgroundAndBorders(paint: ElementPaint): Promise<void>;
51
+ renderDashedDottedBorder(color: Color, width: number, side: number, curvePoints: BoundCurves, style: BORDER_STYLE): Promise<void>;
52
+ render(element: ElementContainer): Promise<HTMLCanvasElement>;
53
+ }
@@ -0,0 +1,11 @@
1
+ import { RenderConfigurations } from "./canvas-renderer";
2
+ import { Renderer } from "../renderer";
3
+ import { Context } from "../../core/context";
4
+ export declare class ForeignObjectRenderer extends Renderer {
5
+ canvas: HTMLCanvasElement;
6
+ ctx: CanvasRenderingContext2D;
7
+ options: RenderConfigurations;
8
+ constructor(context: Context, options: RenderConfigurations);
9
+ render(element: HTMLElement): Promise<HTMLCanvasElement>;
10
+ }
11
+ export declare const loadSerializedSVG: (svg: Node) => Promise<HTMLImageElement>;
@@ -0,0 +1,38 @@
1
+ import { Matrix } from "../css/property-descriptors/transform";
2
+ import { Path } from "./path";
3
+ export declare const enum EffectType {
4
+ TRANSFORM = 0,
5
+ CLIP = 1,
6
+ OPACITY = 2
7
+ }
8
+ export declare const enum EffectTarget {
9
+ BACKGROUND_BORDERS = 2,
10
+ CONTENT = 4
11
+ }
12
+ export interface IElementEffect {
13
+ readonly type: EffectType;
14
+ readonly target: number;
15
+ }
16
+ export declare class TransformEffect implements IElementEffect {
17
+ readonly offsetX: number;
18
+ readonly offsetY: number;
19
+ readonly matrix: Matrix;
20
+ readonly type: EffectType;
21
+ readonly target: number;
22
+ constructor(offsetX: number, offsetY: number, matrix: Matrix);
23
+ }
24
+ export declare class ClipEffect implements IElementEffect {
25
+ readonly path: Path[];
26
+ readonly target: EffectTarget;
27
+ readonly type: EffectType;
28
+ constructor(path: Path[], target: EffectTarget);
29
+ }
30
+ export declare class OpacityEffect implements IElementEffect {
31
+ readonly opacity: number;
32
+ readonly type: EffectType;
33
+ readonly target: number;
34
+ constructor(opacity: number);
35
+ }
36
+ export declare const isTransformEffect: (effect: IElementEffect) => effect is TransformEffect;
37
+ export declare const isClipEffect: (effect: IElementEffect) => effect is ClipEffect;
38
+ export declare const isOpacityEffect: (effect: IElementEffect) => effect is OpacityEffect;
@@ -0,0 +1,11 @@
1
+ export interface FontMetric {
2
+ baseline: number;
3
+ middle: number;
4
+ }
5
+ export declare class FontMetrics {
6
+ private readonly _data;
7
+ private readonly _document;
8
+ constructor(document: Document);
9
+ private parseMetrics;
10
+ getMetrics(fontFamily: string, fontSize: string): FontMetric;
11
+ }
@@ -0,0 +1,13 @@
1
+ import { BezierCurve } from "./bezier-curve";
2
+ import { Vector } from "./vector";
3
+ export declare const enum PathType {
4
+ VECTOR = 0,
5
+ BEZIER_CURVE = 1
6
+ }
7
+ export interface IPath {
8
+ type: PathType;
9
+ add(deltaX: number, deltaY: number): IPath;
10
+ }
11
+ export declare const equalPath: (a: Path[], b: Path[]) => boolean;
12
+ export declare const transformPath: (path: Path[], deltaX: number, deltaY: number, deltaW: number, deltaH: number) => Path[];
13
+ export type Path = Vector | BezierCurve;
@@ -0,0 +1,7 @@
1
+ import { Context } from "../core/context";
2
+ import { RenderConfigurations } from "./canvas/canvas-renderer";
3
+ export declare class Renderer {
4
+ protected readonly context: Context;
5
+ protected readonly options: RenderConfigurations;
6
+ constructor(context: Context, options: RenderConfigurations);
7
+ }
@@ -0,0 +1,27 @@
1
+ import { Font } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { SkiaFontCollection } from "../../fonts/font-collection";
3
+ import { FontStylePojo } from "../../fonts/interfaces";
4
+ import { CSSParsedDeclaration } from "../../css";
5
+ /**
6
+ * Parsed font information from CSS styles
7
+ */
8
+ export interface ParsedFontInfo {
9
+ fontFamily: string[];
10
+ fontSize: number;
11
+ fontStyle: FontStylePojo;
12
+ fontVariant: string;
13
+ }
14
+ export declare function createSkiaFont(styles: CSSParsedDeclaration, fontCollection: SkiaFontCollection): Font;
15
+ /**
16
+ * Parse CSS font styles into Skia-compatible font information
17
+ */
18
+ export declare function parseFontStyle(styles: CSSParsedDeclaration): ParsedFontInfo;
19
+ /**
20
+ * Map CSS font-weight values to Skia FontWeight
21
+ */
22
+ export declare function mapCSSFontWeightToSkia(fontWeight: string | number): number;
23
+ /**
24
+ * Map CSS font-style values to Skia FontSlant
25
+ */
26
+ export declare function mapCSSFontStyleToSkia(fontStyle: string): number;
27
+ export declare function getFinalFont(text: string, styles: CSSParsedDeclaration, originalFont: Font, fontCollection: SkiaFontCollection): Font;
@@ -0,0 +1,69 @@
1
+ import { CanvasKit, Canvas as SkiaCanvas, Paint as SkiaPaint, Path as SkiaPath, PathBuilder, Shader as SkiaShader, Image as SkiaImage, Font as SkiaFont } from "@html2pdf-skia/canvaskit-pdf";
2
+ import { ElementPaint, StackingContext } from "../stacking-context";
3
+ import { Color } from "../../css/types/color";
4
+ import { ElementContainer } from "../../dom/element-container";
5
+ import { BORDER_STYLE } from "../../css/property-descriptors/border-style";
6
+ import { CSSParsedDeclaration } from "../../css";
7
+ import { TextContainer } from "../../dom/text-container";
8
+ import { Path } from "../path";
9
+ import { BoundCurves } from "../bound-curves";
10
+ import { TextBounds } from "../../css/layout/text";
11
+ import { ReplacedElementContainer } from "../../dom/replaced-elements";
12
+ import { IElementEffect } from "../effects";
13
+ import { Context } from "../../core/context";
14
+ import { SkiaFontCollection } from "../../fonts/font-collection";
15
+ export interface CanvasKitConfig {
16
+ canvasKit: CanvasKit;
17
+ canvas: SkiaCanvas;
18
+ }
19
+ export interface SkiaRenderOptions {
20
+ scale: number;
21
+ x: number;
22
+ y: number;
23
+ width: number;
24
+ height: number;
25
+ backgroundColor: Color | null;
26
+ fontCollection: SkiaFontCollection;
27
+ document?: Document;
28
+ onElementContent?: (tagId: number, corners: number[]) => void;
29
+ }
30
+ export declare class SkiaRenderer {
31
+ private context;
32
+ private options;
33
+ canvas: SkiaCanvas;
34
+ canvasKit: CanvasKit;
35
+ private readonly _activeEffects;
36
+ private readonly fontMetrics;
37
+ private readonly globalAlpha;
38
+ constructor(context: Context, ckConfig: CanvasKitConfig, options: SkiaRenderOptions);
39
+ private parseColor;
40
+ /**
41
+ * Parse a color and apply the current global alpha value
42
+ */
43
+ private parseColorWithAlpha;
44
+ private createPaint;
45
+ applyEffects(effects: IElementEffect[]): void;
46
+ applyEffect(effect: IElementEffect): void;
47
+ popEffect(): void;
48
+ renderStack(stack: StackingContext): Promise<void>;
49
+ renderNode(paint: ElementPaint): Promise<void>;
50
+ renderTextWithLetterSpacing(text: TextBounds, letterSpacing: number, baseline: number, paint: SkiaPaint, font: SkiaFont): void;
51
+ renderTextNode(text: TextContainer, styles: CSSParsedDeclaration): void;
52
+ renderReplacedElement(container: ReplacedElementContainer, curves: BoundCurves, image: SkiaImage): void;
53
+ private createSkiaPath;
54
+ renderNodeContent(paint: ElementPaint): Promise<void>;
55
+ renderStackContent(stack: StackingContext): Promise<void>;
56
+ mask(paths: Path[]): void;
57
+ path(paths: Path[]): SkiaPath;
58
+ formatSkiaPath(skiaPath: PathBuilder, paths: Path[]): void;
59
+ renderRepeat(path: Path[], shader: SkiaShader, offsetX: number, offsetY: number): void;
60
+ renderBackgroundImage(container: ElementContainer): Promise<void>;
61
+ renderSolidBorder(color: Color, side: number, curvePoints: BoundCurves): void;
62
+ renderDoubleBorder(color: Color, width: number, side: number, curvePoints: BoundCurves): Promise<void>;
63
+ renderNodeBackgroundAndBorders(paint: ElementPaint): Promise<void>;
64
+ renderDashedDottedBorder(color: Color, width: number, side: number, curvePoints: BoundCurves, style: BORDER_STYLE): void;
65
+ private convertCanvasImageSourceToSkia;
66
+ private convertSvgToSkia;
67
+ render(element: ElementContainer): Promise<void>;
68
+ resizeImage(image: HTMLImageElement, width: number, height: number): HTMLCanvasElement | HTMLImageElement;
69
+ }
@@ -0,0 +1,24 @@
1
+ import { ElementContainer } from "../dom/element-container";
2
+ import { BoundCurves } from "./bound-curves";
3
+ import { EffectTarget, IElementEffect } from "./effects";
4
+ export declare class StackingContext {
5
+ element: ElementPaint;
6
+ negativeZIndex: StackingContext[];
7
+ zeroOrAutoZIndexOrTransformedOrOpacity: StackingContext[];
8
+ positiveZIndex: StackingContext[];
9
+ nonPositionedFloats: StackingContext[];
10
+ nonPositionedInlineLevel: StackingContext[];
11
+ inlineLevel: ElementPaint[];
12
+ nonInlineLevel: ElementPaint[];
13
+ constructor(container: ElementPaint);
14
+ }
15
+ export declare class ElementPaint {
16
+ readonly container: ElementContainer;
17
+ readonly parent: ElementPaint | null;
18
+ readonly effects: IElementEffect[];
19
+ readonly curves: BoundCurves;
20
+ listValue?: string;
21
+ constructor(container: ElementContainer, parent: ElementPaint | null);
22
+ getEffects(target: EffectTarget): IElementEffect[];
23
+ }
24
+ export declare const parseStackingContexts: (container: ElementContainer) => StackingContext;
@@ -0,0 +1,9 @@
1
+ import { IPath, Path, PathType } from "./path";
2
+ export declare class Vector implements IPath {
3
+ type: PathType;
4
+ x: number;
5
+ y: number;
6
+ constructor(x: number, y: number);
7
+ add(deltaX: number, deltaY: number): Vector;
8
+ }
9
+ export declare const isVector: (path: Path) => path is Vector;
Binary file
@@ -0,0 +1,27 @@
1
+ // Copyright 2015 The Chromium Authors
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions are
5
+ // met:
6
+ //
7
+ // * Redistributions of source code must retain the above copyright
8
+ // notice, this list of conditions and the following disclaimer.
9
+ // * Redistributions in binary form must reproduce the above
10
+ // copyright notice, this list of conditions and the following disclaimer
11
+ // in the documentation and/or other materials provided with the
12
+ // distribution.
13
+ // * Neither the name of Google LLC nor the names of its
14
+ // contributors may be used to endorse or promote products derived from
15
+ // this software without specific prior written permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,29 @@
1
+ // Copyright (c) 2011 Google Inc. All rights reserved.
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions are
5
+ // met:
6
+ //
7
+ // * Redistributions of source code must retain the above copyright
8
+ // notice, this list of conditions and the following disclaimer.
9
+ // * Redistributions in binary form must reproduce the above
10
+ // copyright notice, this list of conditions and the following disclaimer
11
+ // in the documentation and/or other materials provided with the
12
+ // distribution.
13
+ // * Neither the name of Google Inc. nor the names of its
14
+ // contributors may be used to endorse or promote products derived from
15
+ // this software without specific prior written permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ --------------------------------------------------------------------------------
@@ -0,0 +1,35 @@
1
+ # CanvasKit PDF source build
2
+
3
+ This package uses Google's BSD-3-Clause Skia CanvasKit 0.42.0 from
4
+ https://skia.googlesource.com/skia.git at
5
+ `e2def78fa232884d4aedcf3ad92d4a0dd673b898`.
6
+ The only additional native implementation is `pdf_bindings.cpp` (MIT).
7
+ It calls SkPDF and exposes `MakePDFDocument`, `SetPDFTagId` and `GetTypefaceId`.
8
+ PDF structure names and numeric attributes are checked before serialization.
9
+
10
+ The builder enables SkPDF in Google's CanvasKit build, adds the bridge, and uses
11
+ CPU rendering, paragraph/font providers and client Unicode (plus SkPDF's
12
+ ICU bidi subset). GPU, Skottie,
13
+ embedded fonts, WOFF2 and tracing are disabled. Consumers supply fonts.
14
+ The upstream mutable Path API became PathBuilder; the library adapts this
15
+ internally without changing PDF export options. Direct CanvasKit consumers
16
+ receive Google's 0.42 API.
17
+
18
+ From the repository root, run `npm run build:canvaskit` to rebuild using Docker.
19
+ `npm run test:canvaskit:rebuild` compares the rebuilt artifacts without replacing
20
+ them. `scripts/canvaskit/build.py` runs inside the pinned Emscripten image;
21
+ Python is not a host requirement. `scripts/canvaskit/build.cjs` starts that image.
22
+ The build overlays two pinned Google build files; it rejects other source edits
23
+ and verifies all selected dependency checkouts against Google's DEPS revisions.
24
+
25
+ `provenance.json` records source and dependency revisions, compiler image digest,
26
+ bridge/build-script hashes and artifact hashes. Hashes alone do not prove trust:
27
+ CI additionally recompiles the source and compares the actual output.
28
+ `LICENSE`, `CHROMIUM-LICENSE` and `THIRD_PARTY_LICENSES.txt` cover upstream code.
29
+ PartitionAlloc's exported repository omits Chromium's root license; the pinned
30
+ primary source URL and digest of that license are recorded separately.
31
+
32
+ The bridge supplies SkPDF tags. The library still finalizes table header links,
33
+ figure bounds, annotation structure, metadata and outlines with pdf-lib.
34
+ Automated fixture results do not establish conformance for every document;
35
+ manual PAC and screen-reader testing remain release checks.