Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@react-pdf/textkit
Advanced tools
@react-pdf/textkit is a low-level text layout engine for React PDF. It provides tools for text shaping, line breaking, and text rendering, making it easier to handle complex text layouts in PDF documents.
Text Shaping
Text shaping involves converting a string of text into a series of positioned glyphs. This is essential for rendering text accurately in PDFs.
const Textkit = require('@react-pdf/textkit');
const font = new Textkit.Font('path/to/font.ttf');
const glyphs = font.layout('Hello, world!');
console.log(glyphs);
Line Breaking
Line breaking is the process of dividing text into lines that fit within a given width. This is crucial for creating readable and well-formatted text blocks in PDFs.
const Textkit = require('@react-pdf/textkit');
const lineBreaker = new Textkit.LineBreaker();
const breaks = lineBreaker.break('This is a long text that needs to be broken into lines.', 100);
console.log(breaks);
Text Rendering
Text rendering involves drawing the shaped and positioned glyphs onto a canvas or PDF. This is the final step in displaying text in a PDF document.
const Textkit = require('@react-pdf/textkit');
const renderer = new Textkit.Renderer();
const text = 'Hello, world!';
const renderedText = renderer.render(text, { x: 0, y: 0 });
console.log(renderedText);
PDFKit is a JavaScript library for generating PDFs. It provides high-level APIs for text rendering, image embedding, and vector graphics. Compared to @react-pdf/textkit, PDFKit is more comprehensive but less specialized in text layout.
pdf-lib is a library for creating and modifying PDF documents in JavaScript. It offers functionalities for text rendering, form creation, and document manipulation. While it provides text rendering capabilities, it lacks the low-level text shaping and line breaking features of @react-pdf/textkit.
split into paragraphs
get bidi runs and paragraph direction
font substitution - map to resolved font runs
script itemization
font shaping - text to glyphs
line breaking
bidi reordering
justification
get a list of rectangles by intersecting path, line, and exclusion paths
perform line breaking to get acceptable break points for each fragment
ellipsize line if necessary
bidi reordering
justification
FAQs
An advanced text layout framework
We found that @react-pdf/textkit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.