How to use the @react-pdf/textkit/attributedString/advanceWidth 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 / render / renderSvgText.js View on Github external
const renderSpan = (ctx, line, textAnchor) => {
  ctx.save();

  const x = R.pathOr(0, ['box', 'x'], line);
  const y = R.pathOr(0, ['box', 'y'], line);
  const width = lineWidth(line);

  switch (textAnchor) {
    case 'middle':
      ctx.translate(x - width / 2, y);
      break;
    case 'end':
      ctx.translate(x - width, y);
      break;
    default:
      ctx.translate(x, y);
      break;
  }

  for (const run of line.runs) {
    renderRun(ctx, run);
  }

@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