takumi-pdf 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/export.d.cts CHANGED
@@ -72,6 +72,14 @@ type PageMargin = PageMarginSide | {
72
72
  bottom?: PageMarginSide;
73
73
  left?: PageMarginSide;
74
74
  };
75
+ /**
76
+ * A page to keep: a 1-based page number, or an inclusive span. An unset `from`
77
+ * starts at the first page; an unset `to` runs to the last.
78
+ */
79
+ type PageRange = number | {
80
+ from?: number;
81
+ to?: number;
82
+ };
75
83
  /**
76
84
  * Paged output (the default): content flows across pages of `size`, like
77
85
  * Puppeteer's `page.pdf()`. The layout canvas has unbounded height, so
@@ -95,6 +103,13 @@ type PagedOptions = {
95
103
  header?: NodeInput;
96
104
  /** Band repeated at the bottom of every page; same class hooks as `header`. */
97
105
  footer?: NodeInput;
106
+ /**
107
+ * The pages the output keeps, e.g. `[1, { from: 4, to: 8 }]`, like a print
108
+ * dialog's page ranges. Layout and page counters still run over the whole
109
+ * document, so a kept page shows the numbers it would in full output.
110
+ * Ranges that keep no page reject the render.
111
+ */
112
+ pageRanges?: PageRange[];
98
113
  };
99
114
  /**
100
115
  * Single-page output: a fixed viewport, like an image render. Percentage
@@ -109,6 +124,7 @@ type ViewportOptions = {
109
124
  margin?: never;
110
125
  header?: never;
111
126
  footer?: never;
127
+ pageRanges?: never;
112
128
  };
113
129
  /**
114
130
  * Options for {@link PdfRenderer.measure}: page geometry (or a viewport) plus
@@ -316,4 +332,4 @@ declare function render(node: NodeInput, options?: RenderOptions): Promise<Uint8
316
332
  /** Measures with a lazily created shared {@link PdfRenderer}. */
317
333
  declare function measure(node: NodeInput, options?: MeasureOptions): Promise<MeasuredSize>;
318
334
  //#endregion
319
- export { ArchivalAttachment, Attachment, type CounterProps, type CounterStyle, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageMarginSide, PageNumber, PageSize, PageSizeName, PdfMetadata, PdfRenderer, RenderOptions, TargetPageNumber, TotalPages, ViewportInput, XmpProperty, XmpSchema, __wbg_init as default, initSync, measure, render };
335
+ export { ArchivalAttachment, Attachment, type CounterProps, type CounterStyle, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageMarginSide, PageNumber, PageRange, PageSize, PageSizeName, PdfMetadata, PdfRenderer, RenderOptions, TargetPageNumber, TotalPages, ViewportInput, XmpProperty, XmpSchema, __wbg_init as default, initSync, measure, render };
package/dist/export.d.mts CHANGED
@@ -72,6 +72,14 @@ type PageMargin = PageMarginSide | {
72
72
  bottom?: PageMarginSide;
73
73
  left?: PageMarginSide;
74
74
  };
75
+ /**
76
+ * A page to keep: a 1-based page number, or an inclusive span. An unset `from`
77
+ * starts at the first page; an unset `to` runs to the last.
78
+ */
79
+ type PageRange = number | {
80
+ from?: number;
81
+ to?: number;
82
+ };
75
83
  /**
76
84
  * Paged output (the default): content flows across pages of `size`, like
77
85
  * Puppeteer's `page.pdf()`. The layout canvas has unbounded height, so
@@ -95,6 +103,13 @@ type PagedOptions = {
95
103
  header?: NodeInput;
96
104
  /** Band repeated at the bottom of every page; same class hooks as `header`. */
97
105
  footer?: NodeInput;
106
+ /**
107
+ * The pages the output keeps, e.g. `[1, { from: 4, to: 8 }]`, like a print
108
+ * dialog's page ranges. Layout and page counters still run over the whole
109
+ * document, so a kept page shows the numbers it would in full output.
110
+ * Ranges that keep no page reject the render.
111
+ */
112
+ pageRanges?: PageRange[];
98
113
  };
99
114
  /**
100
115
  * Single-page output: a fixed viewport, like an image render. Percentage
@@ -109,6 +124,7 @@ type ViewportOptions = {
109
124
  margin?: never;
110
125
  header?: never;
111
126
  footer?: never;
127
+ pageRanges?: never;
112
128
  };
113
129
  /**
114
130
  * Options for {@link PdfRenderer.measure}: page geometry (or a viewport) plus
@@ -316,4 +332,4 @@ declare function render(node: NodeInput, options?: RenderOptions): Promise<Uint8
316
332
  /** Measures with a lazily created shared {@link PdfRenderer}. */
317
333
  declare function measure(node: NodeInput, options?: MeasureOptions): Promise<MeasuredSize>;
318
334
  //#endregion
319
- export { ArchivalAttachment, Attachment, type CounterProps, type CounterStyle, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageMarginSide, PageNumber, PageSize, PageSizeName, PdfMetadata, PdfRenderer, RenderOptions, TargetPageNumber, TotalPages, ViewportInput, XmpProperty, XmpSchema, __wbg_init as default, initSync, measure, render };
335
+ export { ArchivalAttachment, Attachment, type CounterProps, type CounterStyle, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageMarginSide, PageNumber, PageRange, PageSize, PageSizeName, PdfMetadata, PdfRenderer, RenderOptions, TargetPageNumber, TotalPages, ViewportInput, XmpProperty, XmpSchema, __wbg_init as default, initSync, measure, render };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "takumi-pdf",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Render paged PDFs from JSX, HTML, and CSS. No headless browser.",
5
5
  "keywords": [
6
6
  "chromium-free",
@@ -139,7 +139,7 @@
139
139
  "publish-lint": "attw --pack . && publint --strict ."
140
140
  },
141
141
  "dependencies": {
142
- "@takumi-rs/helpers": "2.13.2"
142
+ "@takumi-rs/helpers": "2.13.4"
143
143
  },
144
144
  "devDependencies": {
145
145
  "@types/bun": "^1.4.0",
Binary file