How to use the @react-pdf/textkit/renderers/pdf.render function in @react-pdf/textkit

To help you get started, we’ve selected a few @react-pdf/textkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github diegomura / react-pdf / src / elements / Text.js View on Github external
renderText() {
    const { top, left } = this.getAbsoluteLayout();
    const initialY = this.lines[0] ? this.lines[0].box.y : 0;

    // We translate lines based on Yoga container
    this.root.instance.save();
    this.root.instance.translate(
      left + this.padding.left,
      top + this.padding.top - initialY,
    );
    // Perform actual text rendering on document
    PDFRenderer.render(this.root.instance, [this.lines]);
    setLink(this);
    setDestination(this)


    this.root.instance.restore();
  }
  async render() {
github diegomura / react-pdf / src / render / renderText.js View on Github external
const renderText = (ctx, node) => {
  const { top, left } = node.box;
  const paddingTop = R.pathOr(0, ['box', 'paddingTop'], node);
  const paddingLeft = R.pathOr(0, ['box', 'paddingLeft'], node);
  const initialY = node.lines[0] ? node.lines[0].box.y : 0;

  ctx.save();
  ctx.translate(left + paddingLeft, top + paddingTop - initialY);

  PDFRenderer.render(ctx, [node.lines]);
  ctx.restore();

  return node;
};

@react-pdf/textkit

An advanced text layout framework

MIT
Latest version published 2 months ago

Package Health Score

92 / 100
Full package analysis

Similar packages