UNPKG

pdfmkr

Version:

Generate PDF documents from JavaScript objects

365 lines (248 loc) 12 kB
# Changelog ## [0.6.2] - 2026-06-11 ### Added - `outputIntents` property on `DocumentDefinition` for declaring PDF output intents (e.g. for PDF/A or PDF/X conformance). Accepts raw ICC profile data as `Uint8Array`, removing the need for consumers to depend on `@ralfstx/pdf-core`. - `xmpFragments` property on `DocumentDefinition` for merging custom XMP metadata into the document's auto-generated XMP. This is needed e.g. for declaring PDF/A conformance level alongside output intents. ## [0.6.1] - 2026-03-08 ### Changed - Upgraded `@ralfstx/pdf-core` dependency from 0.1.x to 0.2.x. PDFs now include XMP metadata derived from the document info properties. ### Fixed - TypeScript declaration files (`.d.ts`) for the public API were missing from the published package, breaking type resolution for consumers. ## [0.6.0] - 2026-02-28 ### Added - Text shaping (ligatures and kerning) is now enabled by default for all text. The following text properties have been added to control shaping behavior: - `fontKerning`: Controls kerning (`'normal'` | `'none'`). - `fontVariantLigatures`: Controls ligatures and contextual alternates (`'normal'` | `'none'`). - `fontFeatureSettings`: Low-level control over OpenType features as a `Record<string, boolean>` (e.g. `{ smcp: true, tnum: true }`). - A `language` property (BCP 47 tag) on both the document definition and text properties. The document-level language is written to the PDF catalog (for accessibility). Fonts that provide language-specific typographic behavior (e.g. for Turkish or Serbian) will use the correct glyph forms for the specified language. ### Changed - Replaced `pdf-lib` with `@ralfstx/pdf-core` as the underlying PDF generation library. This results in faster PDF generation and a smaller bundle size. It also opens up new possibilities for new features such as font shaping. ### Removed - Support for font and image data as base64-encoded strings and `ArrayBuffer`. Data must now be provided as `Uint8Array`. - The `images` property in the document definition. Images should be referred to by URL instead. The `ImagesDefinition` and `ImageDefinition` types have been removed. - The `fonts` property in the document definition. Fonts must now be registered with `PdfMaker.registerFont()`. The `FontsDefinition` and `FontDefinition` types have been removed. - The deprecated standalone `makePdf` function. Use `new PdfMaker().makePdf()` instead. - The deprecated `Polyline` and `PolyLineOpts` types from the graphics API. Use `Path` instead. - The deprecated `bold` and `italic` text properties. Use `fontWeight: 'bold'` and `fontStyle: 'italic'` instead. - The deprecated type aliases `InfoAttrs`, `CustomInfoAttrs`, `LineOpts`, `RectOpts`, `CircleOpts`, `PathOpts`, `BlockAttrs`, and `TextAttrs`. Use their `*Props` counterparts instead. ### Breaking - The text height is now correctly based on the OS/2 typographic metrics (`sTypoAscender` / `sTypoDescender` / `sTypoLineGap`) instead of the hhea table values. - The default `lineHeight` multiplier has changed from `1.2` to `1`. Together with the switch from hhea to OS/2 typographic metrics, these changes make line spacing follow the font's own vertical metrics instead of applying a fixed CSS-style multiplier. ## [0.5.6] - 2025-01-19 ### Added - Support for embedded files via the `embeddedFiles` property in the document definition. ### Fixed - A bug that caused errors when reusing fonts or images across multiple documents. ## [0.5.5] - 2024-12-18 The minimum EcmaScript version has been raised to ES2022. Minimum build requirements have been raised to Node 20 and npm 10. ### Added - The functions `line()`, `rect()`, `circle()`, and `path()` to create graphics shapes with less code and better tool support. - The functions `text()`, `image()`, `rows()`, and `columns()` to create blocks with less code and better tool support. - The function `span()` to create text spans with less code and better tool support. - The functions `bold()` and `italic()` to conveniently create text spans with bold or italic styles. - The `PdfMaker` class to render multiple documents with the same font configuration. ```ts const pdfMaker = new PdfMaker(config); pdfMaker.registerFont(await readFile('path/to/MyFont.ttf')); pdfMaker.registerFont(await readFile('path/to/MyFont-Bold.ttf')); const pdf1 = await pdfMaker.makePdf(doc1); const pdf2 = await pdfMaker.makePdf(doc2); ``` ### Changed - Fonts should now be registered with the `registerFont()` method on the `PdfMaker` class. - The `image` property of an image block now supports `data:`, `file:`, and `http(s):` URLs. File names are relative to a resource root that must be set by the `setResourceRoot()` method on the `PdfMaker` class. ### Deprecated - `TextAttrs` in favor of `TextProps`. - `BlockAttrs` in favor of `BlockProps`. - `InfoAttrs` in favor of `InfoProps`. - `CustomInfoAttrs` in favor of `CustomInfoProps`. - `Text` in favor of `TextSpan`. - `LineOpts` in favor of `StrokeProps`. - `RectOpts` in favor of `RectProps`. - `CircleOpts` in favor of `CircleProps`. - `PathOpts` in favor of `PathProps`. - The `fonts` property in a document definition. - The `images` property in a document definition. - The `makePdf` function in favor of the `makePdf` method on the `PdfMaker` class. - Using file paths as image sources in favor of `file:` URLs. ## [0.5.4] - 2024-02-25 ### Added - Text properties `fontStyle` and `fontWeight`. ### Changed - The `image` property of an image block now supports a file name. When file names are used, the images don't need to be registered with the global `images` property anymore. ### Deprecated - Text properties `bold` and `italic` in favor of `fontStyle: 'italic'` and `fontWeight: 'bold'`. ### Removed - The optional `format` property of an image definition. The format is now auto-detected from the file content. ### Fixed - Text in a text block will no longer break before the first row, which would result in an empty frame. ## [0.5.3] - 2023-09-28 ### Fixed - An edge case that could lead to a duplicated row after a page break has been fixed. ## [0.5.2] - 2023-07-06 ### Added - The `width` property of a `Block` now supports the value `auto` on all block types. When set to `auto`, the block will shrink to the width of its contents. ## [0.5.1] - 2023-06-30 ### Added - The property `margin` in a document definition now supports a function that returns the margin for a given page. - Support for PNG images. A new, optional property `format` is added to image definitions. For PNG images, it must be set to `png` (defaults to `jpeg`). ### Fixed - In the PDF metadata, the fields "Creator" and "Producer" are no longer set to default values. - Consecutive newlines in texts are no longer collapsed. Blank lines are now rendered as expected. - Images registered in the document definition are now only included in the PDF when they are used in the document. ## [0.5.0] - 2023-05-18 ### Breaking changes - When a graphics element has neither `lineColor` nor `fillColor` set, it is stroked by default. If a `lineWidth` but no `lineColor` is set on an element that also has a `fillColor`, the element is now stroked with a black line. - Rows in a `RowsBlock` will now break and continue on the next page when they do not fit. To prevent this, set `breakInside` to `avoid`. - Lines in a `TextBlock` will now break and continue on the next page when they do not fit. To prevent this, set `breakInside` to `avoid`. - The `lineJoin` property is no longer supported by the graphics type `Circle`. ### Added - Property `breakInside` to control page breaks inside a block on `TextBlock` and `RowsBlock`. The default is `auto`. - Property `insertAfterBreak` on `RowsBlock` to insert an extra block after a page break. - Properties `translate`, `scale`, `rotate`, `skew` and `matrix` on all graphics elements to apply transformations. ## [0.4.2] - 2023-04-29 ### Added - Text property `letterSpacing`. - Support for SVG paths in `graphics` using `Path` elements. ## [0.4.1] - 2023-04-15 (not available) Note: This npm package `pdfmkr@0.4.1` had to be unpublished because of a build error. Do to npm's policy, the version number cannot be reused. ### Fixed - Text rise is now reset properly and does not affect subsequent text elements anymore. ## [0.4.0] - 2023-03-27 ### Breaking changes - Page margins are now relative to the header and footer to let the contents adjust to a dynamic header and footer height. ### Added - Text property `rise` for superscripts and subscripts. - Block property `verticalAlign` for vertical alignment of columns. - Property `lineDash` for graphics shapes. ## [0.3.3] - 2023-03-03 ### Fixed - An error was thrown when rendering a document definition that includes a `header` but no `footer`. ## [0.3.2] - 2022-10-12 ### Added - Property `customData` to include custom data in the PDF _document catalog_. ## [0.3.1] - 2022-08-25 ### Fixed - PDF now has a trailing newline - Link annotations are now compatible with PDF/A - The PDF trailer now has an ID (needed for PDF/A compatibility) ## [0.3.0] - 2022-07-28 ### Breaking changes - Renamed block types `Paragraph` to `TextBlock`, `Image` to `ImageBlock`, `Columns` to `ColumnsBlock`, and `Rows` to `RowsBlock`. Added `EmptyBlock` for blocks that don't have any content. ### Added - Graphics shape type `circle`. - Properties `lineOpacity` and `fillOpacity` on graphics shapes. - Property `padding` on _all_ block types. - Properties `breakBefore` and `breakAfter` on top-level blocks. - Margins and paddings are highlighted when guides are enabled. ### Fixed - Property `imageAlign` marked optional in type definition - Copied text from a PDF document now includes headers and footers in correct order ## [0.2.0] - 2022-06-08 ### Breaking changes - Properties `strokeWidth`, `strokeColor` have been renamed to `lineWidth`, `lineColor`. - Images are horizontally centered by default. - Text is now vertically aligned in text rows. ### Added - Properties `lineCap` and `lineJoin`. - Support for functions in the `graphics` property. - Property `imageAlign` for horizontal alignment. - Property `pageSize` and `pageOrientation`. ### Fixed - Position of anchors in PDF does not include the padding or paragraphs anymore. ## [0.1.0] - 2022-04-25 First public version. [0.1.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.1.0 [0.2.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.2.0 [0.3.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.3.0 [0.3.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.3.0 [0.3.1]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.3.1 [0.3.2]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.3.2 [0.3.3]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.3.3 [0.4.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.4.0 [0.4.1]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.4.1 [0.4.2]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.4.2 [0.5.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.0 [0.5.1]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.1 [0.5.2]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.2 [0.5.3]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.3 [0.5.4]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.4 [0.5.5]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.5 [0.5.6]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.5.6 [0.6.0]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.6.0 [0.6.1]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.6.1 [0.6.2]: https://github.com/eclipsesource/pdf-maker/releases/tag/v0.6.2