pagyra-js 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +338 -264
- package/dist/assets/fonts/licenses/selawik/SIL Open Font License.txt +43 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Black.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/dejavu/DejaVuSans.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Light.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Medium.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-SemiBold.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Light.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Medium.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-SemiBold.ttf +0 -0
- package/dist/assets/fonts/ttf/notosans/NotoSans-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawk.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawkb.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawkl.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawksb.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawksl.ttf +0 -0
- package/dist/assets/fonts/ttf/stixtwomath/STIXTwoMath-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Regular.ttf +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-400-italic.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-400-normal.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-700-italic.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-700-normal.woff +0 -0
- package/dist/assets/fonts/woff2/caveat/Caveat-Bold.woff2 +0 -0
- package/dist/assets/fonts/woff2/caveat/Caveat-Regular.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-400-italic.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-400-normal.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-700-italic.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-700-normal.woff2 +0 -0
- package/dist/browser/pagyra.min.js +34 -34
- package/dist/browser/pagyra.min.js.map +4 -4
- package/dist/playground/server.js +2 -0
- package/dist/src/css/compute-style/base-options.d.ts +7 -0
- package/dist/src/css/compute-style/base-options.js +24 -0
- package/dist/src/css/compute-style/declarations.d.ts +10 -0
- package/dist/src/css/compute-style/declarations.js +77 -0
- package/dist/src/css/compute-style/decoration.d.ts +8 -0
- package/dist/src/css/compute-style/decoration.js +55 -0
- package/dist/src/css/compute-style/defaults.d.ts +3 -0
- package/dist/src/css/compute-style/defaults.js +34 -0
- package/dist/src/css/compute-style/display.d.ts +3 -0
- package/dist/src/css/compute-style/display.js +85 -0
- package/dist/src/css/compute-style/float.d.ts +2 -0
- package/dist/src/css/compute-style/float.js +13 -0
- package/dist/src/css/compute-style/font.d.ts +12 -0
- package/dist/src/css/compute-style/font.js +57 -0
- package/dist/src/css/compute-style/overrides.d.ts +3 -0
- package/dist/src/css/compute-style/overrides.js +241 -0
- package/dist/src/css/compute-style.d.ts +2 -0
- package/dist/src/css/compute-style.js +34 -487
- package/dist/src/css/enums.d.ts +4 -0
- package/dist/src/css/enums.js +5 -0
- package/dist/src/css/layout-property-resolver.js +30 -18
- package/dist/src/css/length.d.ts +26 -2
- package/dist/src/css/length.js +48 -0
- package/dist/src/css/parsers/background-parser.js +1 -1
- package/dist/src/css/parsers/calc-parser.d.ts +2 -0
- package/dist/src/css/parsers/calc-parser.js +310 -0
- package/dist/src/css/parsers/content-parser.d.ts +2 -1
- package/dist/src/css/parsers/content-parser.js +7 -2
- package/dist/src/css/parsers/dimension-parser.js +37 -18
- package/dist/src/css/parsers/display-flex-parser.d.ts +4 -0
- package/dist/src/css/parsers/display-flex-parser.js +97 -0
- package/dist/src/css/parsers/filter-parser.d.ts +14 -0
- package/dist/src/css/parsers/filter-parser.js +255 -0
- package/dist/src/css/parsers/grid-parser-extended.d.ts +1 -0
- package/dist/src/css/parsers/grid-parser-extended.js +40 -1
- package/dist/src/css/parsers/grid-parser.d.ts +5 -2
- package/dist/src/css/parsers/grid-parser.js +71 -7
- package/dist/src/css/parsers/length-parser.d.ts +8 -3
- package/dist/src/css/parsers/length-parser.js +45 -2
- package/dist/src/css/parsers/margin-block-parser.js +3 -3
- package/dist/src/css/parsers/margin-parser.js +3 -3
- package/dist/src/css/parsers/padding-block-parser.js +3 -3
- package/dist/src/css/parsers/padding-inline-parser.js +3 -3
- package/dist/src/css/parsers/padding-parser.js +6 -6
- package/dist/src/css/parsers/position-parser.js +2 -22
- package/dist/src/css/parsers/register-parsers.js +29 -2
- package/dist/src/css/parsers/word-break-parser.d.ts +2 -0
- package/dist/src/css/parsers/word-break-parser.js +23 -0
- package/dist/src/css/properties/grid.d.ts +16 -2
- package/dist/src/css/properties/layout.d.ts +3 -1
- package/dist/src/css/properties/layout.js +1 -1
- package/dist/src/css/properties/misc.d.ts +5 -0
- package/dist/src/css/properties/typography.d.ts +3 -0
- package/dist/src/css/properties/visual.d.ts +36 -0
- package/dist/src/css/shorthands/box-shorthand.d.ts +2 -2
- package/dist/src/css/style-inheritance.d.ts +2 -1
- package/dist/src/css/style-inheritance.js +1 -0
- package/dist/src/css/style.d.ts +30 -10
- package/dist/src/css/style.js +8 -1
- package/dist/src/css/ua-defaults/base-defaults.d.ts +1 -0
- package/dist/src/css/ua-defaults/base-defaults.js +10 -1
- package/dist/src/css/ua-defaults/element-defaults.js +0 -2
- package/dist/src/html/css/parse-css.d.ts +2 -0
- package/dist/src/html/css/parse-css.js +32 -3
- package/dist/src/html/dom-converter/background-images.d.ts +3 -0
- package/dist/src/html/dom-converter/background-images.js +88 -0
- package/dist/src/html/dom-converter/convert-dom-node.d.ts +5 -0
- package/dist/src/html/dom-converter/convert-dom-node.js +81 -0
- package/dist/src/html/dom-converter/handlers/br-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/br-handler.js +20 -0
- package/dist/src/html/dom-converter/handlers/form-control-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/form-control-handler.js +28 -0
- package/dist/src/html/dom-converter/handlers/img-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/img-handler.js +4 -0
- package/dist/src/html/dom-converter/handlers/index.d.ts +4 -0
- package/dist/src/html/dom-converter/handlers/index.js +19 -0
- package/dist/src/html/dom-converter/handlers/svg-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/svg-handler.js +32 -0
- package/dist/src/html/dom-converter/handlers/types.d.ts +12 -0
- package/dist/src/html/dom-converter/handlers/types.js +2 -0
- package/dist/src/html/dom-converter/helpers.d.ts +7 -0
- package/dist/src/html/dom-converter/helpers.js +35 -0
- package/dist/src/html/dom-converter/index.d.ts +1 -0
- package/dist/src/html/dom-converter/index.js +1 -0
- package/dist/src/html/dom-converter/pseudo-elements.d.ts +6 -0
- package/dist/src/html/dom-converter/pseudo-elements.js +48 -0
- package/dist/src/html/dom-converter/text.d.ts +15 -0
- package/dist/src/html/dom-converter/text.js +170 -0
- package/dist/src/html/dom-converter.d.ts +1 -5
- package/dist/src/html/dom-converter.js +1 -417
- package/dist/src/html/image-converter.d.ts +5 -0
- package/dist/src/html-to-pdf/document-css.d.ts +14 -0
- package/dist/src/html-to-pdf/document-css.js +45 -0
- package/dist/src/html-to-pdf/fonts.d.ts +16 -0
- package/dist/src/html-to-pdf/fonts.js +74 -0
- package/dist/src/html-to-pdf/header-footer.d.ts +14 -0
- package/dist/src/html-to-pdf/header-footer.js +101 -0
- package/dist/src/html-to-pdf/html-parser.d.ts +6 -0
- package/dist/src/html-to-pdf/html-parser.js +81 -0
- package/dist/src/html-to-pdf/index.d.ts +3 -0
- package/dist/src/html-to-pdf/index.js +2 -0
- package/dist/src/html-to-pdf/layout-build.d.ts +37 -0
- package/dist/src/html-to-pdf/layout-build.js +73 -0
- package/dist/src/html-to-pdf/prepare-html-render.d.ts +2 -0
- package/dist/src/html-to-pdf/prepare-html-render.js +121 -0
- package/dist/src/html-to-pdf/render-finalize.d.ts +15 -0
- package/dist/src/html-to-pdf/render-finalize.js +27 -0
- package/dist/src/html-to-pdf/render-html-to-pdf.d.ts +3 -0
- package/dist/src/html-to-pdf/render-html-to-pdf.js +25 -0
- package/dist/src/html-to-pdf/resource-loader.d.ts +6 -0
- package/dist/src/html-to-pdf/resource-loader.js +120 -0
- package/dist/src/html-to-pdf/types.d.ts +38 -0
- package/dist/src/html-to-pdf/types.js +2 -0
- package/dist/src/html-to-pdf.d.ts +1 -37
- package/dist/src/html-to-pdf.js +1 -537
- package/dist/src/layout/counter.d.ts +1 -2
- package/dist/src/layout/counter.js +18 -18
- package/dist/src/layout/inline/inline-utils.d.ts +1 -1
- package/dist/src/layout/inline/inline-utils.js +8 -7
- package/dist/src/layout/inline/layout.js +16 -3
- package/dist/src/layout/inline/run-placer.d.ts +1 -0
- package/dist/src/layout/inline/run-placer.js +3 -11
- package/dist/src/layout/pipeline/out-of-flow-manager.js +25 -1
- package/dist/src/layout/strategies/block.js +35 -24
- package/dist/src/layout/strategies/flex.js +305 -61
- package/dist/src/layout/strategies/form.d.ts +2 -0
- package/dist/src/layout/strategies/form.js +38 -13
- package/dist/src/layout/strategies/grid.js +165 -31
- package/dist/src/layout/strategies/image.js +53 -27
- package/dist/src/layout/strategies/inline.js +26 -21
- package/dist/src/layout/strategies/table.js +26 -18
- package/dist/src/layout/utils/content-measurer.d.ts +1 -1
- package/dist/src/layout/utils/content-measurer.js +8 -7
- package/dist/src/layout/utils/floats.d.ts +1 -0
- package/dist/src/layout/utils/floats.js +14 -12
- package/dist/src/layout/utils/margin.d.ts +4 -4
- package/dist/src/layout/utils/margin.js +20 -16
- package/dist/src/layout/utils/node-math.d.ts +12 -6
- package/dist/src/layout/utils/node-math.js +71 -41
- package/dist/src/layout/utils/sizing.js +2 -1
- package/dist/src/pdf/font/embedder.js +3 -3
- package/dist/src/pdf/font/font-subset.js +1 -3
- package/dist/src/pdf/font/to-unicode.js +16 -16
- package/dist/src/pdf/font-subset/font-registry.d.ts +6 -0
- package/dist/src/pdf/font-subset/font-registry.js +30 -2
- package/dist/src/pdf/header-footer-renderer.js +12 -1
- package/dist/src/pdf/layout-tree-builder.js +5 -1
- package/dist/src/pdf/page-painter.js +13 -0
- package/dist/src/pdf/pagination.js +2 -2
- package/dist/src/pdf/renderer/box-painter.js +28 -3
- package/dist/src/pdf/renderer/page-paint.js +11 -3
- package/dist/src/pdf/renderers/radius-utils.js +31 -38
- package/dist/src/pdf/renderers/shape-renderer.js +1 -1
- package/dist/src/pdf/renderers/shape-utils.js +1 -1
- package/dist/src/pdf/renderers/text-renderer.d.ts +9 -1
- package/dist/src/pdf/renderers/text-renderer.js +36 -2
- package/dist/src/pdf/stacking/build-stacking-contexts.js +1 -2
- package/dist/src/pdf/stacking/resolve-paint-order.d.ts +5 -6
- package/dist/src/pdf/stacking/resolve-paint-order.js +29 -9
- package/dist/src/pdf/stacking/types.d.ts +14 -0
- package/dist/src/pdf/svg/shape-renderer.js +47 -20
- package/dist/src/pdf/types.d.ts +7 -1
- package/dist/src/pdf/utils/border-radius-utils.js +31 -38
- package/dist/src/pdf/utils/color-utils.js +17 -2
- package/dist/src/pdf/utils/filter-utils.d.ts +29 -0
- package/dist/src/pdf/utils/filter-utils.js +85 -0
- package/dist/src/pdf/utils/node-text-run-factory.js +1 -27
- package/dist/src/pdf/utils/text-layout-adjuster.d.ts +0 -8
- package/dist/src/pdf/utils/text-layout-adjuster.js +12 -9
- package/dist/src/units/units.d.ts +1 -1
- package/dist/tests/css/box-sizing.spec.js +46 -0
- package/dist/tests/css/calc-parser.spec.d.ts +1 -0
- package/dist/tests/css/calc-parser.spec.js +68 -0
- package/dist/tests/css/container-query-units.spec.d.ts +1 -0
- package/dist/tests/css/container-query-units.spec.js +64 -0
- package/dist/tests/css/content-parser.spec.js +13 -0
- package/dist/tests/css/filter-parser.spec.d.ts +1 -0
- package/dist/tests/css/filter-parser.spec.js +116 -0
- package/dist/tests/css/flex-shorthand.spec.d.ts +1 -0
- package/dist/tests/css/flex-shorthand.spec.js +45 -0
- package/dist/tests/css/grid-clamp.spec.d.ts +1 -0
- package/dist/tests/css/grid-clamp.spec.js +82 -0
- package/dist/tests/css/parse-css-pseudo.spec.d.ts +1 -0
- package/dist/tests/css/parse-css-pseudo.spec.js +26 -0
- package/dist/tests/environment/path-resolution.spec.js +2 -1
- package/dist/tests/helpers/ai-layout-diagnostics.js +6 -6
- package/dist/tests/helpers/render-utils.d.ts +18 -2
- package/dist/tests/helpers/render-utils.js +25 -12
- package/dist/tests/html/dom-converter-pseudo-elements.spec.d.ts +1 -0
- package/dist/tests/html/dom-converter-pseudo-elements.spec.js +33 -0
- package/dist/tests/html/dom-converter-text.spec.d.ts +1 -0
- package/dist/tests/html/dom-converter-text.spec.js +67 -0
- package/dist/tests/layout/box-sizing.spec.d.ts +1 -0
- package/dist/tests/layout/box-sizing.spec.js +75 -0
- package/dist/tests/layout/calc-padding.spec.d.ts +1 -0
- package/dist/tests/layout/calc-padding.spec.js +19 -0
- package/dist/tests/layout/container-query-units.spec.d.ts +1 -0
- package/dist/tests/layout/container-query-units.spec.js +17 -0
- package/dist/tests/layout/flex-auto-height.spec.d.ts +1 -0
- package/dist/tests/layout/flex-auto-height.spec.js +35 -0
- package/dist/tests/layout/flex-wrap-cards.spec.d.ts +1 -0
- package/dist/tests/layout/flex-wrap-cards.spec.js +16 -0
- package/dist/tests/layout/flex-wrap-grow-align-content.spec.d.ts +1 -0
- package/dist/tests/layout/flex-wrap-grow-align-content.spec.js +20 -0
- package/dist/tests/layout/grid-clamp-gap.spec.d.ts +1 -0
- package/dist/tests/layout/grid-clamp-gap.spec.js +22 -0
- package/dist/tests/layout/inline-background-alignment.spec.js +6 -6
- package/dist/tests/layout/inline-fragments.spec.js +38 -0
- package/dist/tests/layout/paged-body-margin.spec.d.ts +1 -0
- package/dist/tests/layout/paged-body-margin.spec.js +92 -0
- package/dist/tests/layout/pseudo-counters-generated-content.spec.d.ts +1 -0
- package/dist/tests/layout/pseudo-counters-generated-content.spec.js +51 -0
- package/dist/tests/layout/responsive-clamp-grid-parity.spec.d.ts +1 -0
- package/dist/tests/layout/responsive-clamp-grid-parity.spec.js +75 -0
- package/dist/tests/layout/run-placer-baseline.spec.js +13 -11
- package/dist/tests/pdf/alignments.spec.js +12 -12
- package/dist/tests/pdf/backdrop-filter-noop.spec.d.ts +1 -0
- package/dist/tests/pdf/backdrop-filter-noop.spec.js +140 -0
- package/dist/tests/pdf/filter-drop-shadow.spec.d.ts +1 -0
- package/dist/tests/pdf/filter-drop-shadow.spec.js +74 -0
- package/dist/tests/pdf/filter-opacity.spec.d.ts +1 -0
- package/dist/tests/pdf/filter-opacity.spec.js +30 -0
- package/dist/tests/pdf/selawik-opt-in.spec.d.ts +1 -0
- package/dist/tests/pdf/selawik-opt-in.spec.js +106 -0
- package/dist/tests/pdf/svg-stroke-dash.spec.js +8 -8
- package/dist/tests/pdf/system-ui-fallback-subset-regression.spec.d.ts +1 -0
- package/dist/tests/pdf/system-ui-fallback-subset-regression.spec.js +39 -0
- package/dist/tests/pdf/text-renderer-fallback.spec.js +55 -0
- package/dist/tests/pdf/text-transform-matrix.spec.js +9 -8
- package/dist/tests/pdf/xref-integrity.spec.js +1 -1
- package/dist/tests/verify-subset-multi.spec.js +14 -14
- package/dist/tests/verify-subset.spec.js +12 -12
- package/package.json +89 -71
- package/dist/tests/pdf/header-footer.spec.js +0 -46
- /package/dist/tests/{pdf/header-footer.spec.d.ts → css/box-sizing.spec.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,117 +1,174 @@
|
|
|
1
|
-
# Pagyra-js
|
|
2
|
-
|
|
3
|
-
A TypeScript-based HTML to PDF converter library with comprehensive CSS 3 support and advanced layout capabilities.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
# Pagyra-js
|
|
2
|
+
|
|
3
|
+
A TypeScript-based HTML to PDF converter library with comprehensive CSS 3 support and advanced layout capabilities.
|
|
4
|
+
|
|
5
|
+
> [▶ Test here using our playground](https://celsowm.github.io/pagyra-js/)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### Core Capabilities
|
|
10
|
+
- **HTML to PDF Conversion**: Convert HTML content to PDF with precise layout control
|
|
11
|
+
- **Comprehensive CSS Support**: Full CSS parsing, inheritance, and layout support
|
|
12
|
+
- **Advanced Text Handling**: Complete text layout with overflow wrapping, justification, and text transformation
|
|
13
|
+
- **Font Management**: Built-in font support with custom font embedding via `@font-face`
|
|
14
|
+
- **Cross-Platform**: Works in both Node.js and browser environments
|
|
15
|
+
|
|
16
|
+
### Recent Additions (from CHANGELOG)
|
|
17
|
+
- **Overflow Wrapping**: Full `overflow-wrap` / `word-wrap` parsing and layout support
|
|
18
|
+
- **Relative Units**: Support for `em`/`rem` units using inherited/root font sizes
|
|
19
|
+
- **Text Transformation**: `text-transform` parsing and rendering (uppercase/lowercase/capitalize)
|
|
20
|
+
- **SVG Stroke Support**: `stroke-dasharray` and `stroke-dashoffset` for dashed line rendering
|
|
21
|
+
- **CSS Variables**: Custom properties with inheritance and `var()` function resolution
|
|
22
|
+
- **Justified Text**: Consistent justified spacing across all inline fragments
|
|
23
|
+
|
|
24
|
+
## 📦 Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install pagyra-js
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Minimal Example (HTML only)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { renderHtmlToPdf } from 'pagyra-js';
|
|
36
|
+
|
|
37
|
+
// Minimal usage - only HTML is required
|
|
38
|
+
// Other parameters will use sensible defaults (A4 size, standard margins)
|
|
39
|
+
const pdfBytes = await renderHtmlToPdf({
|
|
40
|
+
html: '<h1>Hello World</h1><p>This is a PDF generated from HTML!</p>'
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Basic Example with Full Control
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { renderHtmlToPdf } from 'pagyra-js';
|
|
48
|
+
|
|
49
|
+
const pdfBytes = await renderHtmlToPdf({
|
|
50
|
+
html: '<h1>Hello World</h1><p>This is a PDF generated from HTML!</p>',
|
|
51
|
+
css: 'body { font-family: Arial; } h1 { color: blue; }',
|
|
52
|
+
viewportWidth: 800,
|
|
53
|
+
viewportHeight: 600,
|
|
54
|
+
pageWidth: 800,
|
|
55
|
+
pageHeight: 1100,
|
|
56
|
+
margins: { top: 20, right: 20, bottom: 20, left: 20 }
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Save or use the PDF bytes
|
|
60
|
+
fs.writeFileSync('output.pdf', Buffer.from(pdfBytes));
|
|
61
|
+
```
|
|
62
|
+
|
|
61
63
|
### Advanced Example with Custom Fonts
|
|
62
64
|
|
|
63
65
|
```typescript
|
|
64
66
|
import { renderHtmlToPdf } from 'pagyra-js';
|
|
65
|
-
|
|
66
|
-
const pdfBytes = await renderHtmlToPdf({
|
|
67
|
-
html: `
|
|
68
|
-
<div class="container">
|
|
69
|
-
<h1>Advanced PDF Example</h1>
|
|
70
|
-
<p class="justified">This text will be justified and use custom fonts.</p>
|
|
71
|
-
<div class="box">Styled box with border-radius</div>
|
|
72
|
-
</div>
|
|
73
|
-
`,
|
|
74
|
-
css: `
|
|
75
|
-
@font-face {
|
|
76
|
-
font-family: 'CustomFont';
|
|
77
|
-
src: url('/path/to/font.woff2') format('woff2');
|
|
78
|
-
font-weight: normal;
|
|
79
|
-
}
|
|
80
|
-
body {
|
|
81
|
-
font-family: 'CustomFont', Arial;
|
|
82
|
-
font-size: 14px;
|
|
83
|
-
}
|
|
84
|
-
.justified {
|
|
85
|
-
text-align: justify;
|
|
86
|
-
overflow-wrap: break-word;
|
|
87
|
-
}
|
|
88
|
-
.box {
|
|
89
|
-
width: 200px;
|
|
90
|
-
height: 100px;
|
|
91
|
-
background-color: #f0f0f0;
|
|
92
|
-
border-radius: 8px;
|
|
93
|
-
border: 1px solid #ccc;
|
|
94
|
-
}
|
|
95
|
-
`,
|
|
96
|
-
viewportWidth: 1000,
|
|
97
|
-
viewportHeight: 800,
|
|
98
|
-
pageWidth: 1000,
|
|
99
|
-
pageHeight: 1400,
|
|
100
|
-
margins: { top: 30, right: 30, bottom: 30, left: 30 },
|
|
101
|
-
fontConfig: {
|
|
102
|
-
fontFaceDefs: [
|
|
103
|
-
{
|
|
104
|
-
name: 'CustomFont',
|
|
105
|
-
family: 'CustomFont',
|
|
106
|
-
src: '/path/to/font.woff2',
|
|
107
|
-
weight: 400,
|
|
108
|
-
style: 'normal'
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
67
|
+
|
|
68
|
+
const pdfBytes = await renderHtmlToPdf({
|
|
69
|
+
html: `
|
|
70
|
+
<div class="container">
|
|
71
|
+
<h1>Advanced PDF Example</h1>
|
|
72
|
+
<p class="justified">This text will be justified and use custom fonts.</p>
|
|
73
|
+
<div class="box">Styled box with border-radius</div>
|
|
74
|
+
</div>
|
|
75
|
+
`,
|
|
76
|
+
css: `
|
|
77
|
+
@font-face {
|
|
78
|
+
font-family: 'CustomFont';
|
|
79
|
+
src: url('/path/to/font.woff2') format('woff2');
|
|
80
|
+
font-weight: normal;
|
|
81
|
+
}
|
|
82
|
+
body {
|
|
83
|
+
font-family: 'CustomFont', Arial;
|
|
84
|
+
font-size: 14px;
|
|
85
|
+
}
|
|
86
|
+
.justified {
|
|
87
|
+
text-align: justify;
|
|
88
|
+
overflow-wrap: break-word;
|
|
89
|
+
}
|
|
90
|
+
.box {
|
|
91
|
+
width: 200px;
|
|
92
|
+
height: 100px;
|
|
93
|
+
background-color: #f0f0f0;
|
|
94
|
+
border-radius: 8px;
|
|
95
|
+
border: 1px solid #ccc;
|
|
96
|
+
}
|
|
97
|
+
`,
|
|
98
|
+
viewportWidth: 1000,
|
|
99
|
+
viewportHeight: 800,
|
|
100
|
+
pageWidth: 1000,
|
|
101
|
+
pageHeight: 1400,
|
|
102
|
+
margins: { top: 30, right: 30, bottom: 30, left: 30 },
|
|
103
|
+
fontConfig: {
|
|
104
|
+
fontFaceDefs: [
|
|
105
|
+
{
|
|
106
|
+
name: 'CustomFont',
|
|
107
|
+
family: 'CustomFont',
|
|
108
|
+
src: '/path/to/font.woff2',
|
|
109
|
+
weight: 400,
|
|
110
|
+
style: 'normal'
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Selawik Opt-in Example (TTF local)
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import path from 'node:path';
|
|
121
|
+
import { renderHtmlToPdf } from 'pagyra-js';
|
|
122
|
+
|
|
123
|
+
const css = `
|
|
124
|
+
@font-face {
|
|
125
|
+
font-family: 'Selawik';
|
|
126
|
+
src: url('ttf/selawik/selawkl.ttf') format('truetype');
|
|
127
|
+
font-weight: 300;
|
|
128
|
+
font-style: normal;
|
|
129
|
+
}
|
|
130
|
+
@font-face {
|
|
131
|
+
font-family: 'Selawik';
|
|
132
|
+
src: url('ttf/selawik/selawksl.ttf') format('truetype');
|
|
133
|
+
font-weight: 300;
|
|
134
|
+
font-style: normal;
|
|
135
|
+
}
|
|
136
|
+
@font-face {
|
|
137
|
+
font-family: 'Selawik';
|
|
138
|
+
src: url('ttf/selawik/selawk.ttf') format('truetype');
|
|
139
|
+
font-weight: 400;
|
|
140
|
+
font-style: normal;
|
|
141
|
+
}
|
|
142
|
+
@font-face {
|
|
143
|
+
font-family: 'Selawik';
|
|
144
|
+
src: url('ttf/selawik/selawksb.ttf') format('truetype');
|
|
145
|
+
font-weight: 600;
|
|
146
|
+
font-style: normal;
|
|
147
|
+
}
|
|
148
|
+
@font-face {
|
|
149
|
+
font-family: 'Selawik';
|
|
150
|
+
src: url('ttf/selawik/selawkb.ttf') format('truetype');
|
|
151
|
+
font-weight: 700;
|
|
152
|
+
font-style: normal;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
body {
|
|
156
|
+
font-family: 'Selawik', 'DejaVu Sans', 'Arimo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
157
|
+
}
|
|
158
|
+
`;
|
|
159
|
+
|
|
160
|
+
const pdfBytes = await renderHtmlToPdf({
|
|
161
|
+
html: '<p>HTML→PDF Stress • sem JS • sem fixed/sticky</p>',
|
|
162
|
+
css,
|
|
163
|
+
resourceBaseDir: path.resolve(process.cwd(), 'assets/fonts'),
|
|
164
|
+
assetRootDir: path.resolve(process.cwd(), 'assets/fonts')
|
|
112
165
|
});
|
|
113
166
|
```
|
|
114
167
|
|
|
168
|
+
Notes:
|
|
169
|
+
- Pagyra does not load `.zip` files directly. Extract the archive and reference `.ttf` files in `@font-face`.
|
|
170
|
+
- Keep symbol-capable fallbacks (`DejaVu Sans`, `Arimo`) for robust rendering of arrows, bullets, and similar glyphs.
|
|
171
|
+
|
|
115
172
|
### Header and Footer Example
|
|
116
173
|
|
|
117
174
|
```typescript
|
|
@@ -159,28 +216,28 @@ Notes:
|
|
|
159
216
|
## API Reference
|
|
160
217
|
|
|
161
218
|
### Main Functions
|
|
162
|
-
|
|
163
|
-
#### `renderHtmlToPdf(options: RenderHtmlOptions): Promise<Uint8Array>`
|
|
164
|
-
|
|
165
|
-
Converts HTML to PDF and returns the PDF as a Uint8Array.
|
|
166
|
-
|
|
167
|
-
**Parameters:**
|
|
168
|
-
|
|
169
|
-
**Mandatory Parameters:**
|
|
170
|
-
- `html`: HTML content string (the only truly required parameter)
|
|
171
|
-
|
|
172
|
-
**Optional Parameters (with sensible defaults available):**
|
|
173
|
-
- `css`: CSS styles string (defaults to empty string)
|
|
174
|
-
- `viewportWidth`: Viewport width in pixels (can be calculated from page size)
|
|
175
|
-
- `viewportHeight`: Viewport height in pixels (can be calculated from page size)
|
|
176
|
-
- `pageWidth`: Page width in pixels (defaults to A4 width: ~595pt/8.27in)
|
|
177
|
-
- `pageHeight`: Page height in pixels (defaults to A4 height: ~841pt/11.69in)
|
|
178
|
-
- `margins`: Page margins in pixels (defaults to standard A4 margins: ~36pt/0.5in all sides)
|
|
179
|
-
- `debug`: Enable debug logging (optional, defaults to false)
|
|
180
|
-
- `debugLevel`: Debug log level (optional)
|
|
181
|
-
- `debugCats`: Debug categories (optional)
|
|
182
|
-
- `fontConfig`: Font configuration (optional, loads built-in fonts by default)
|
|
183
|
-
- `resourceBaseDir`: Base directory for resource resolution (optional)
|
|
219
|
+
|
|
220
|
+
#### `renderHtmlToPdf(options: RenderHtmlOptions): Promise<Uint8Array>`
|
|
221
|
+
|
|
222
|
+
Converts HTML to PDF and returns the PDF as a Uint8Array.
|
|
223
|
+
|
|
224
|
+
**Parameters:**
|
|
225
|
+
|
|
226
|
+
**Mandatory Parameters:**
|
|
227
|
+
- `html`: HTML content string (the only truly required parameter)
|
|
228
|
+
|
|
229
|
+
**Optional Parameters (with sensible defaults available):**
|
|
230
|
+
- `css`: CSS styles string (defaults to empty string)
|
|
231
|
+
- `viewportWidth`: Viewport width in pixels (can be calculated from page size)
|
|
232
|
+
- `viewportHeight`: Viewport height in pixels (can be calculated from page size)
|
|
233
|
+
- `pageWidth`: Page width in pixels (defaults to A4 width: ~595pt/8.27in)
|
|
234
|
+
- `pageHeight`: Page height in pixels (defaults to A4 height: ~841pt/11.69in)
|
|
235
|
+
- `margins`: Page margins in pixels (defaults to standard A4 margins: ~36pt/0.5in all sides)
|
|
236
|
+
- `debug`: Enable debug logging (optional, defaults to false)
|
|
237
|
+
- `debugLevel`: Debug log level (optional)
|
|
238
|
+
- `debugCats`: Debug categories (optional)
|
|
239
|
+
- `fontConfig`: Font configuration (optional, loads built-in fonts by default)
|
|
240
|
+
- `resourceBaseDir`: Base directory for resource resolution (optional)
|
|
184
241
|
- `assetRootDir`: Asset root directory (optional)
|
|
185
242
|
- `headerFooter`: Header/footer configuration (optional)
|
|
186
243
|
- `environment`: Environment abstraction (Node/browser, optional - defaults to Node environment)
|
|
@@ -193,138 +250,155 @@ Converts HTML to PDF and returns the PDF as a Uint8Array.
|
|
|
193
250
|
- `maxHeaderHeightPx`, `maxFooterHeightPx`: reserved space in pixels (optional, auto-measured if omitted)
|
|
194
251
|
- `layerMode`: `"under"` (default) or `"over"`
|
|
195
252
|
- `clipOverflow`, `fontFamily`, `placeholders` (advanced)
|
|
196
|
-
|
|
197
|
-
**Note:** While the TypeScript interface requires all parameters, in practice only `html` is truly mandatory. The playground server demonstrates how to compute reasonable defaults for other parameters using helper functions like `sanitizeDimension()` and `resolvePageMarginsPx()`.
|
|
198
|
-
|
|
199
|
-
#### `prepareHtmlRender(options: RenderHtmlOptions): Promise<PreparedRender>`
|
|
200
|
-
|
|
201
|
-
Prepares HTML for rendering without generating the final PDF. Useful for debugging layout.
|
|
202
|
-
|
|
203
|
-
**Returns:**
|
|
204
|
-
- `layoutRoot`: Root layout node
|
|
205
|
-
- `renderTree`: Render tree structure
|
|
206
|
-
- `pageSize`: Page dimensions in points
|
|
207
|
-
- `margins`: Applied margins
|
|
208
|
-
|
|
209
|
-
### CSS Support
|
|
210
|
-
|
|
211
|
-
Pagyra-js supports a comprehensive set of CSS properties:
|
|
212
|
-
|
|
213
|
-
- **Layout**: `display`, `position`, `float`, `clear`, `z-index`
|
|
214
|
-
- **Box Model**: `width`, `height`, `margin`, `padding`, `border`, `box-sizing`
|
|
215
|
-
- **Flexbox**: `flex-direction`, `flex-wrap`, `justify-content`, `align-items`, etc.
|
|
216
|
-
- **Grid**: `grid-template`, `grid-gap`, `grid-auto-flow`
|
|
217
|
-
- **Text**: `font-family`, `font-size`, `font-weight`, `line-height`, `text-align`, `text-transform`, `overflow-wrap`
|
|
218
|
-
- **Colors**: `color`, `background-color`, `opacity`
|
|
219
|
-
- **Spacing**: `gap`, `margin-block`, `margin-inline`
|
|
220
|
-
- **Units**: `px`, `em`, `rem`, `pt`, `mm`, `cm`, `in`, `%`
|
|
221
|
-
- **Custom Properties**: CSS variables with `var()`
|
|
222
|
-
|
|
223
|
-
### Font Configuration
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
interface FontConfig {
|
|
227
|
-
fontFaceDefs: Array<{
|
|
228
|
-
name: string;
|
|
229
|
-
family: string;
|
|
230
|
-
src: string;
|
|
231
|
-
data?: ArrayBuffer; // Font data (required for browser environment)
|
|
232
|
-
weight: number;
|
|
233
|
-
style: 'normal' | 'italic';
|
|
234
|
-
}>;
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
For a detailed guide on how to work with custom fonts in Vite and browser environments, see [Embedding Fonts](docs/font-embedding.md).
|
|
239
|
-
|
|
240
|
-
## Development
|
|
241
|
-
|
|
242
|
-
### Project Structure
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
src/
|
|
246
|
-
├── core.ts # Core exports and types
|
|
247
|
-
├── html-to-pdf.ts # Main HTML to PDF conversion logic
|
|
248
|
-
├── index.ts # Main entry point
|
|
249
|
-
├── browser-entry.ts # Browser-specific entry point
|
|
250
|
-
├── css/ # CSS parsing and styling
|
|
251
|
-
├── dom/ # DOM node handling
|
|
252
|
-
├── html/ # HTML parsing and conversion
|
|
253
|
-
├── layout/ # Layout calculation engine
|
|
254
|
-
├── pdf/ # PDF generation and rendering
|
|
255
|
-
├── svg/ # SVG support
|
|
256
|
-
├── units/ # Unit conversion utilities
|
|
257
|
-
└── ... (other modules)
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Build Process
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
# Install dependencies
|
|
264
|
-
npm install
|
|
265
|
-
|
|
266
|
-
# Build the project
|
|
267
|
-
npm run build
|
|
268
|
-
|
|
269
|
-
# Run tests
|
|
270
|
-
npm test
|
|
271
|
-
|
|
272
|
-
# Run linter
|
|
273
|
-
npm run lint
|
|
274
|
-
|
|
275
|
-
# Run playground (Node environment)
|
|
276
|
-
npm run playground
|
|
277
|
-
|
|
278
|
-
# Run browser playground
|
|
279
|
-
npm run playground:browser
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Development Scripts
|
|
283
|
-
|
|
284
|
-
- `npm run build`: Compile TypeScript to JavaScript
|
|
285
|
-
- `npm run clean`: Remove build artifacts
|
|
286
|
-
- `npm run test`: Run test suite
|
|
287
|
-
- `npm run lint`: Run ESLint
|
|
288
|
-
- `npm run playground`: Interactive development environment
|
|
289
|
-
- `npm run playground:browser`: Browser-based playground
|
|
290
|
-
- `npm run build:browser`: Build browser bundle
|
|
291
|
-
|
|
292
|
-
## Browser Support
|
|
293
|
-
|
|
294
|
-
Pagyra-js can run in browser environments with some configuration:
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
import { renderHtmlToPdfBrowser } from 'pagyra-js/browser
|
|
298
|
-
|
|
299
|
-
// Use the browser-specific entry point
|
|
300
|
-
const pdfBytes = await renderHtmlToPdfBrowser({
|
|
301
|
-
html: '<p>Browser PDF generation</p>',
|
|
302
|
-
css: 'body { font-family: Arial; }',
|
|
303
|
-
// ... other options
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
253
|
+
|
|
254
|
+
**Note:** While the TypeScript interface requires all parameters, in practice only `html` is truly mandatory. The playground server demonstrates how to compute reasonable defaults for other parameters using helper functions like `sanitizeDimension()` and `resolvePageMarginsPx()`.
|
|
255
|
+
|
|
256
|
+
#### `prepareHtmlRender(options: RenderHtmlOptions): Promise<PreparedRender>`
|
|
257
|
+
|
|
258
|
+
Prepares HTML for rendering without generating the final PDF. Useful for debugging layout.
|
|
259
|
+
|
|
260
|
+
**Returns:**
|
|
261
|
+
- `layoutRoot`: Root layout node
|
|
262
|
+
- `renderTree`: Render tree structure
|
|
263
|
+
- `pageSize`: Page dimensions in points
|
|
264
|
+
- `margins`: Applied margins
|
|
265
|
+
|
|
266
|
+
### CSS Support
|
|
267
|
+
|
|
268
|
+
Pagyra-js supports a comprehensive set of CSS properties:
|
|
269
|
+
|
|
270
|
+
- **Layout**: `display`, `position`, `float`, `clear`, `z-index`
|
|
271
|
+
- **Box Model**: `width`, `height`, `margin`, `padding`, `border`, `box-sizing`
|
|
272
|
+
- **Flexbox**: `flex-direction`, `flex-wrap`, `justify-content`, `align-items`, etc.
|
|
273
|
+
- **Grid**: `grid-template`, `grid-gap`, `grid-auto-flow`
|
|
274
|
+
- **Text**: `font-family`, `font-size`, `font-weight`, `line-height`, `text-align`, `text-transform`, `overflow-wrap`
|
|
275
|
+
- **Colors**: `color`, `background-color`, `opacity`
|
|
276
|
+
- **Spacing**: `gap`, `margin-block`, `margin-inline`
|
|
277
|
+
- **Units**: `px`, `em`, `rem`, `pt`, `mm`, `cm`, `in`, `%`
|
|
278
|
+
- **Custom Properties**: CSS variables with `var()`
|
|
279
|
+
|
|
280
|
+
### Font Configuration
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
interface FontConfig {
|
|
284
|
+
fontFaceDefs: Array<{
|
|
285
|
+
name: string;
|
|
286
|
+
family: string;
|
|
287
|
+
src: string;
|
|
288
|
+
data?: ArrayBuffer; // Font data (required for browser environment)
|
|
289
|
+
weight: number;
|
|
290
|
+
style: 'normal' | 'italic';
|
|
291
|
+
}>;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
For a detailed guide on how to work with custom fonts in Vite and browser environments, see [Embedding Fonts](docs/font-embedding.md).
|
|
296
|
+
|
|
297
|
+
## Development
|
|
298
|
+
|
|
299
|
+
### Project Structure
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
src/
|
|
303
|
+
├── core.ts # Core exports and types
|
|
304
|
+
├── html-to-pdf.ts # Main HTML to PDF conversion logic
|
|
305
|
+
├── index.ts # Main entry point
|
|
306
|
+
├── browser-entry.ts # Browser-specific entry point
|
|
307
|
+
├── css/ # CSS parsing and styling
|
|
308
|
+
├── dom/ # DOM node handling
|
|
309
|
+
├── html/ # HTML parsing and conversion
|
|
310
|
+
├── layout/ # Layout calculation engine
|
|
311
|
+
├── pdf/ # PDF generation and rendering
|
|
312
|
+
├── svg/ # SVG support
|
|
313
|
+
├── units/ # Unit conversion utilities
|
|
314
|
+
└── ... (other modules)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Build Process
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# Install dependencies
|
|
321
|
+
npm install
|
|
322
|
+
|
|
323
|
+
# Build the project
|
|
324
|
+
npm run build
|
|
325
|
+
|
|
326
|
+
# Run tests
|
|
327
|
+
npm test
|
|
328
|
+
|
|
329
|
+
# Run linter
|
|
330
|
+
npm run lint
|
|
331
|
+
|
|
332
|
+
# Run playground (Node environment)
|
|
333
|
+
npm run playground
|
|
334
|
+
|
|
335
|
+
# Run browser playground
|
|
336
|
+
npm run playground:browser
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Development Scripts
|
|
340
|
+
|
|
341
|
+
- `npm run build`: Compile TypeScript to JavaScript
|
|
342
|
+
- `npm run clean`: Remove build artifacts
|
|
343
|
+
- `npm run test`: Run test suite
|
|
344
|
+
- `npm run lint`: Run ESLint
|
|
345
|
+
- `npm run playground`: Interactive development environment
|
|
346
|
+
- `npm run playground:browser`: Browser-based playground
|
|
347
|
+
- `npm run build:browser`: Build browser bundle
|
|
348
|
+
|
|
349
|
+
## 🌐 Browser Support
|
|
350
|
+
|
|
351
|
+
Pagyra-js can run in browser environments with some configuration:
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
import { renderHtmlToPdfBrowser } from 'pagyra-js/browser';
|
|
355
|
+
|
|
356
|
+
// Use the browser-specific entry point
|
|
357
|
+
const pdfBytes = await renderHtmlToPdfBrowser({
|
|
358
|
+
html: '<p>Browser PDF generation</p>',
|
|
359
|
+
css: 'body { font-family: Arial; }',
|
|
360
|
+
// ... other options supported by the browser entrypoint
|
|
361
|
+
});
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### CDN
|
|
365
|
+
|
|
366
|
+
The minified browser bundle is published at:
|
|
367
|
+
|
|
368
|
+
```text
|
|
369
|
+
https://cdn.jsdelivr.net/npm/pagyra-js@latest/dist/browser/pagyra.min.js
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Use it from a module script:
|
|
373
|
+
|
|
374
|
+
```html
|
|
375
|
+
<script type="module">
|
|
376
|
+
import { renderHtmlToPdfBrowser } from "https://cdn.jsdelivr.net/npm/pagyra-js@latest/dist/browser/pagyra.min.js";
|
|
377
|
+
|
|
378
|
+
// ...
|
|
379
|
+
</script>
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## 🧪 Examples
|
|
383
|
+
|
|
384
|
+
Check the `playground/public/examples/` directory for various usage examples:
|
|
385
|
+
- Basic HTML to PDF conversion
|
|
386
|
+
- CSS layout demonstrations
|
|
387
|
+
- SVG rendering examples
|
|
388
|
+
- Advanced text formatting
|
|
389
|
+
- Custom font usage
|
|
390
|
+
|
|
391
|
+
## Contributing
|
|
392
|
+
|
|
393
|
+
Contributions are welcome! Please follow these guidelines:
|
|
394
|
+
|
|
395
|
+
1. Fork the repository
|
|
396
|
+
2. Create a feature branch
|
|
397
|
+
3. Implement your changes
|
|
398
|
+
4. Add tests for new functionality
|
|
399
|
+
5. Run `npm run lint` and `npm test`
|
|
400
|
+
6. Submit a pull request
|
|
401
|
+
|
|
402
|
+
## License
|
|
403
|
+
|
|
404
|
+
MIT License
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Copyright 2015, Microsoft Corporation (www.microsoft.com), with Reserved Font Name Selawik. All Rights Reserved. Selawik is a trademark of Microsoft Corporation in the United States and/or other countries.
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------
|
|
7
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
PREAMBLE
|
|
11
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
|
|
12
|
+
|
|
13
|
+
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
|
|
14
|
+
|
|
15
|
+
DEFINITIONS
|
|
16
|
+
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
|
|
17
|
+
|
|
18
|
+
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
|
|
19
|
+
|
|
20
|
+
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
|
|
21
|
+
|
|
22
|
+
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
|
|
23
|
+
|
|
24
|
+
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
|
|
25
|
+
|
|
26
|
+
PERMISSION & CONDITIONS
|
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
|
|
28
|
+
|
|
29
|
+
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
|
|
30
|
+
|
|
31
|
+
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
|
|
32
|
+
|
|
33
|
+
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
|
|
34
|
+
|
|
35
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
|
|
36
|
+
|
|
37
|
+
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
|
|
38
|
+
|
|
39
|
+
TERMINATION
|
|
40
|
+
This license becomes null and void if any of the above conditions are not met.
|
|
41
|
+
|
|
42
|
+
DISCLAIMER
|
|
43
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|