Skip to content

💥 Replace pdf-lib with pdf-core, bump to 0.6.0#102

Merged
ralfstx merged 1 commit intomainfrom
pdf-core
Feb 14, 2026
Merged

💥 Replace pdf-lib with pdf-core, bump to 0.6.0#102
ralfstx merged 1 commit intomainfrom
pdf-core

Conversation

@ralfstx
Copy link
Member

@ralfstx ralfstx commented Feb 14, 2026

This change replaces pdf-lib and fontkit with @ralfstx/pdf-core as the underlying PDF generation library. This results in faster PDF generation, smaller bundle size, and opens up new possibilities such as font shaping.

Loading font and image data from base64-encoded strings was a feature of pdf-lib. Reading encoded data should better be done outside of the library, so we drop this feature and require Uint8Array.

With pdf-core, we can directly use the OS/2 typographic metrics for font metrics instead of relying on the hhea table values. This is the correct approach but it results in tighter line spacing for fonts whose hhea values include extra spacing that was effectively double-counted with the lineHeight multiplier.

Links and anchors are supported by pdf-core, so the custom rendering code is removed. Parsing JPEG and PNG data is also handled by pdf-core, so the related code is removed. Rendering functions are simplified to use the ContentStream API directly.

The version is bumped to 0.6.0 to account for the breaking changes in the API.

This change replaces `pdf-lib` and `fontkit` with `@ralfstx/pdf-core` as
the underlying PDF generation library. This results in faster PDF
generation, smaller bundle size, and opens up new possibilities such as
font shaping.

Loading font and image data from base64-encoded strings was a feature of
`pdf-lib`. Reading encoded data should better be done outside of the
library, so we drop this feature and require `Uint8Array`.

With `pdf-core`, we can directly use the OS/2 typographic metrics for
font metrics instead of relying on the hhea table values. This is the
correct approach but it results in tighter line spacing for fonts whose
hhea values include extra spacing that was effectively double-counted
with the `lineHeight` multiplier.

Links and anchors are supported by `pdf-core`, so the custom rendering
code is removed. Parsing JPEG and PNG data is also handled by
`pdf-core`, so the related code is removed. Rendering functions are
simplified to use the `ContentStream` API directly.

The version is bumped to 0.6.0 to account for the breaking changes in
the API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ralfstx ralfstx merged commit 22a526b into main Feb 14, 2026
1 check passed
@ralfstx ralfstx deleted the pdf-core branch February 14, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant