🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@react-pdf/textkit

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf/textkit

An advanced text layout framework

2.0.5
Version published
Maintainers
1
Created

What is @react-pdf/textkit?

@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.

What are @react-pdf/textkit's main functionalities?

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);

Other packages similar to @react-pdf/textkit

FAQs

Package last updated on 05 Jun 2021

Did you know?

Socket

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.

Install

Related posts