@embedpdf/engine-services 3.0.0-next.5 → 3.0.0-next.6

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.cjs CHANGED
@@ -4173,6 +4173,14 @@ const BOX_FAMILY_SUBTYPES = /* @__PURE__ */ new Set([
4173
4173
  14
4174
4174
  ]);
4175
4175
  /**
4176
+ * Per-appearance output-pixel ceiling (see the clamp in `renderOne`).
4177
+ * 16 M px ≈ a 4000² raster ≈ 64 MB of transient RGBA — safely inside the
4178
+ * wasm heap for the one-at-a-time batch loop, while a page-sized annotation
4179
+ * stays crisp to roughly 5–6× before its appearance starts stretching.
4180
+ * Small annotations (the overwhelming majority) never come near it.
4181
+ */
4182
+ const APPEARANCE_PIXEL_CLAMP = 16e6;
4183
+ /**
4176
4184
  * Maps an `AnnotationAppearanceMode` onto the PDFium appearance-mode int and
4177
4185
  * the `EPDFAnnot_GetAvailableAppearanceModes` bit it occupies.
4178
4186
  * N -> mode 0 / bit 1, R -> mode 1 / bit 2, D -> mode 2 / bit 4.
@@ -4271,13 +4279,15 @@ var AnnotationAppearanceReader = class {
4271
4279
  fn.EPDFAnnot_GenerateFormFieldAP(annotPtr);
4272
4280
  if (!fn.EPDFAnnot_HasAppearanceStream(annotPtr, modeInt)) return null;
4273
4281
  } else return null;
4282
+ const rectArea = Math.max(1, (rect.right - rect.left) * (rect.top - rect.bottom));
4283
+ const effScale = Math.min(scale, Math.sqrt(APPEARANCE_PIXEL_CLAMP / rectArea));
4274
4284
  return rasterize(this.runtime, {
4275
4285
  rect,
4276
4286
  page,
4277
4287
  rotation,
4278
4288
  viewport: {
4279
4289
  kind: "scale",
4280
- scale
4290
+ scale: effScale
4281
4291
  },
4282
4292
  ...maxOutputPixels !== void 0 ? { maxOutputPixels } : {},
4283
4293
  background: "transparent",