pdfnative 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5499,6 +5499,7 @@ var DEFAULT_TEXT_COLOR = "0.75 0.75 0.75";
5499
5499
  var DEFAULT_TEXT_OPACITY = 0.15;
5500
5500
  var DEFAULT_TEXT_ANGLE = -45;
5501
5501
  var DEFAULT_IMAGE_OPACITY = 0.1;
5502
+ var DEFAULT_CAP_HEIGHT_RATIO = 0.718;
5502
5503
  function validateWatermark(watermark, pdfaLevel) {
5503
5504
  if (pdfaLevel === "pdfa1b") {
5504
5505
  const textOpacity = watermark.text?.opacity ?? DEFAULT_TEXT_OPACITY;
@@ -5553,10 +5554,12 @@ function _buildTextWatermarkOps(wm, pgW, pgH, enc, gsName) {
5553
5554
  const cy = pgH / 2;
5554
5555
  const textWidth = enc.tw(wm.text, sz);
5555
5556
  const offsetX = -textWidth / 2;
5556
- const offsetY = -sz / 2;
5557
+ const fd = enc.fontData;
5558
+ const capHeightRatio = fd ? fd.metrics.capHeight / fd.metrics.unitsPerEm : DEFAULT_CAP_HEIGHT_RATIO;
5559
+ const offsetY = -sz * capHeightRatio / 2;
5557
5560
  const tx = cx + offsetX * cos - offsetY * sin;
5558
5561
  const ty = cy + offsetX * sin + offsetY * cos;
5559
- const escapedText = pdfString(wm.text);
5562
+ const escapedText = enc.ps(wm.text);
5560
5563
  const ops = [
5561
5564
  "q",
5562
5565
  `${gsName} gs`,