cantoo-scribe / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
136 stars 27 forks source link

Add text outline/stroke option #52

Closed alexbrazier closed 6 months ago

alexbrazier commented 6 months ago

What?

Added more text rendering options to add text stroke

page5.drawText('This text is outlined', {
  x: 30,
  y: 80,
  font: helveticaFont,
  color: hotPink,
  strokeColor: blue,
  strokeWidth: 1.5,
  renderMode: TextRenderingMode.FillAndOutline,
});

page5.drawText('Outline only', {
  x: 30,
  y: 10,
  font: helveticaFont,
  strokeColor: hotPink,
  strokeWidth: 1.5,
  renderMode: TextRenderingMode.Outline,
});

Why?

Issues like this: https://github.com/Hopding/pdf-lib/issues/763

Used manually on https://github.com/squareda/pdf-print-marks/blob/main/src/addMetadata.ts#L16 to add outlined text so it's more visible on unknown backgrounds

How?

Testing?

Added test to render some outlined text

New Dependencies?

No

Screenshots

image

Suggested Reading?

Yes

Anything Else?

Checklist

Sharcoux commented 6 months ago

Released in v1.21.1

Thanks a lot for your contribution!