@embedpdf/engines 1.0.7 → 1.0.8
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 +405 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +101 -56
- package/dist/index.js +406 -259
- package/dist/index.js.map +1 -1
- package/dist/pdfium-direct-engine.cjs +379 -232
- package/dist/pdfium-direct-engine.cjs.map +1 -1
- package/dist/pdfium-direct-engine.d.ts +95 -50
- package/dist/pdfium-direct-engine.js +380 -233
- package/dist/pdfium-direct-engine.js.map +1 -1
- package/dist/pdfium-worker-engine.cjs +21 -21
- package/dist/pdfium-worker-engine.cjs.map +1 -1
- package/dist/pdfium-worker-engine.d.ts +7 -7
- package/dist/pdfium-worker-engine.js +21 -21
- package/dist/pdfium-worker-engine.js.map +1 -1
- package/dist/pdfium.cjs +382 -235
- package/dist/pdfium.cjs.map +1 -1
- package/dist/pdfium.d.ts +95 -50
- package/dist/pdfium.js +383 -236
- package/dist/pdfium.js.map +1 -1
- package/dist/preact.cjs +4 -3
- package/dist/preact.cjs.map +1 -1
- package/dist/preact.d.ts +4 -3
- package/dist/preact.js +4 -3
- package/dist/preact.js.map +1 -1
- package/dist/react.cjs +4 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +4 -3
- package/dist/react.js +4 -3
- package/dist/react.js.map +1 -1
- package/dist/worker.cjs +20 -20
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +7 -7
- package/dist/worker.js +20 -20
- package/dist/worker.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, ImageConversionTypes, PdfTask, Rect, PdfAnnotationObject,
|
|
1
|
+
import { PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, ImageConversionTypes, PdfTask, Rect, PdfAnnotationObject, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PageTextSlice, PdfInkAnnoObject, PdfHighlightAnnoObject, PdfUnderlineAnnoObject, PdfStrikeOutAnnoObject, PdfSquigglyAnnoObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, AppearanceMode, PdfAnnotationObjectBase, WebAlphaColor, MatchFlag, SearchAllPagesResult, PdfImage } from '@embedpdf/models';
|
|
2
2
|
import { WrappedPdfiumModule } from '@embedpdf/pdfium';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -163,12 +163,6 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
163
163
|
* @returns PdfTask<boolean> – true on success
|
|
164
164
|
*/
|
|
165
165
|
updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
|
|
166
|
-
/**
|
|
167
|
-
* {@inheritDoc @embedpdf/models!PdfEngine.transformPageAnnotation}
|
|
168
|
-
*
|
|
169
|
-
* @public
|
|
170
|
-
*/
|
|
171
|
-
transformPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, transformation: PdfAnnotationTransformation): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
|
|
172
166
|
/**
|
|
173
167
|
* {@inheritDoc @embedpdf/models!PdfEngine.removePageAnnotation}
|
|
174
168
|
*
|
|
@@ -283,7 +277,7 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
283
277
|
*
|
|
284
278
|
* @private
|
|
285
279
|
*/
|
|
286
|
-
addInkStroke(page: PdfPageObject, pagePtr: number, annotationPtr: number,
|
|
280
|
+
addInkStroke(page: PdfPageObject, pagePtr: number, annotationPtr: number, annotation: PdfInkAnnoObject): boolean;
|
|
287
281
|
/**
|
|
288
282
|
* Add highlight content to annotation
|
|
289
283
|
* @param page - page info
|
|
@@ -293,7 +287,7 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
293
287
|
*
|
|
294
288
|
* @private
|
|
295
289
|
*/
|
|
296
|
-
addTextMarkupContent(page: PdfPageObject, annotationPtr: number, annotation: PdfHighlightAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfSquigglyAnnoObject
|
|
290
|
+
addTextMarkupContent(page: PdfPageObject, pagePtr: number, annotationPtr: number, annotation: PdfHighlightAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfSquigglyAnnoObject): boolean;
|
|
297
291
|
/**
|
|
298
292
|
* Add contents to stamp annotation
|
|
299
293
|
* @param docPtr - pointer to pdf document object
|
|
@@ -449,47 +443,6 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
449
443
|
* @private
|
|
450
444
|
*/
|
|
451
445
|
private readAnnotationColor;
|
|
452
|
-
/**
|
|
453
|
-
* Extract the fill (or, if absent, the stroke) colour from a **path object**
|
|
454
|
-
* inside an appearance stream.
|
|
455
|
-
*
|
|
456
|
-
* Works for simple highlights produced by Chrome, Preview, etc. that paint a
|
|
457
|
-
* single filled rectangle with the desired tint.
|
|
458
|
-
*
|
|
459
|
-
* @param pathPtr - pointer to a `FPDF_PAGEOBJECT` of type **PATH**
|
|
460
|
-
* @returns RGBA tuple or `undefined` when no colour is set on the path
|
|
461
|
-
*
|
|
462
|
-
* @private
|
|
463
|
-
*/
|
|
464
|
-
private getColorFromPath;
|
|
465
|
-
/**
|
|
466
|
-
* Recursively walk a page-object tree (PATHs and nested FORM XObjects) until
|
|
467
|
-
* a colour can be extracted.
|
|
468
|
-
*
|
|
469
|
-
* Acrobat often wraps its highlight rectangle in a Form XObject referenced by
|
|
470
|
-
* the "Do" operator, so this function drills down unlimited depth.
|
|
471
|
-
*
|
|
472
|
-
* @param objPtr - pointer to a `FPDF_PAGEOBJECT`
|
|
473
|
-
* @returns First RGBA tint found, or `undefined` if none of the descendants
|
|
474
|
-
* carry an explicit fill/stroke colour
|
|
475
|
-
*
|
|
476
|
-
* @private
|
|
477
|
-
*/
|
|
478
|
-
private walkPageObjTree;
|
|
479
|
-
/**
|
|
480
|
-
* Iterate over every top-level object in the annotation's **appearance stream**
|
|
481
|
-
* and invoke {@link walkPageObjTree} to locate a usable tint.
|
|
482
|
-
*
|
|
483
|
-
* Catches:
|
|
484
|
-
* • Simple filled path (Preview, Chrome)
|
|
485
|
-
* • Form XObject containing the path (Acrobat)
|
|
486
|
-
*
|
|
487
|
-
* @param annotPtr - pointer to an `FPDF_ANNOTATION`
|
|
488
|
-
* @returns RGBA tuple or `undefined` when no colour can be resolved from AP
|
|
489
|
-
*
|
|
490
|
-
* @private
|
|
491
|
-
*/
|
|
492
|
-
private colorFromAppearance;
|
|
493
446
|
/**
|
|
494
447
|
* Resolve the visible fill colour for **Highlight / Underline / StrikeOut /
|
|
495
448
|
* Squiggly** markup annotations.
|
|
@@ -518,6 +471,57 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
518
471
|
* @private
|
|
519
472
|
*/
|
|
520
473
|
private setAnnotationColor;
|
|
474
|
+
/**
|
|
475
|
+
* Border‐style + width helper
|
|
476
|
+
*
|
|
477
|
+
* Tries the new PDFium helper `EPDFAnnot_GetBorderStyle()` (patch series
|
|
478
|
+
* 9 July 2025).
|
|
479
|
+
*
|
|
480
|
+
* @param annotationPtr pointer to an `FPDF_ANNOTATION`
|
|
481
|
+
* @returns `{ ok, style, width }`
|
|
482
|
+
* • `ok` – `true` when the call succeeded
|
|
483
|
+
* • `style` – `PdfAnnotationBorderStyle` enum
|
|
484
|
+
* • `width` – stroke-width in points (defaults to 0 pt)
|
|
485
|
+
*/
|
|
486
|
+
private getBorderStyle;
|
|
487
|
+
private setBorderStyle;
|
|
488
|
+
/**
|
|
489
|
+
* Border-effect (“cloudy”) helper
|
|
490
|
+
*
|
|
491
|
+
* Calls the new PDFium function `EPDFAnnot_GetBorderEffect()` (July 2025).
|
|
492
|
+
*
|
|
493
|
+
* @param annotationPtr pointer to an `FPDF_ANNOTATION`
|
|
494
|
+
* @returns `{ ok, intensity }`
|
|
495
|
+
* • `ok` – `true` when the annotation *does* have a
|
|
496
|
+
* valid cloudy-border effect
|
|
497
|
+
* • `intensity` – radius/intensity value (0 when `ok` is false)
|
|
498
|
+
*/
|
|
499
|
+
private getBorderEffect;
|
|
500
|
+
/**
|
|
501
|
+
* Rectangle-differences helper ( /RD array on Square / Circle annots )
|
|
502
|
+
*
|
|
503
|
+
* Calls `EPDFAnnot_GetRectangleDifferences()` introduced in July 2025.
|
|
504
|
+
*
|
|
505
|
+
* @param annotationPtr pointer to an `FPDF_ANNOTATION`
|
|
506
|
+
* @returns `{ ok, left, top, right, bottom }`
|
|
507
|
+
* • `ok` – `true` when the annotation *has* an /RD entry
|
|
508
|
+
* • the four floats are 0 when `ok` is false
|
|
509
|
+
*/
|
|
510
|
+
private getRectangleDifferences;
|
|
511
|
+
/**
|
|
512
|
+
* Dash-pattern helper ( /BS → /D array, dashed borders only )
|
|
513
|
+
*
|
|
514
|
+
* Uses the two new PDFium helpers:
|
|
515
|
+
* • `EPDFAnnot_GetBorderDashPatternCount`
|
|
516
|
+
* • `EPDFAnnot_GetBorderDashPattern`
|
|
517
|
+
*
|
|
518
|
+
* @param annotationPtr pointer to an `FPDF_ANNOTATION`
|
|
519
|
+
* @returns `{ ok, pattern }`
|
|
520
|
+
* • `ok` – `true` when the annot is dashed *and* the array
|
|
521
|
+
* was retrieved successfully
|
|
522
|
+
* • `pattern` – numeric array of dash/space lengths (empty when `ok` is false)
|
|
523
|
+
*/
|
|
524
|
+
private getBorderDashPattern;
|
|
521
525
|
/**
|
|
522
526
|
* Read `/QuadPoints` from any annotation and convert each quadrilateral to
|
|
523
527
|
* device-space coordinates.
|
|
@@ -545,6 +549,21 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
545
549
|
* @private
|
|
546
550
|
*/
|
|
547
551
|
private syncQuadPointsAnno;
|
|
552
|
+
/**
|
|
553
|
+
* Read ink list from annotation
|
|
554
|
+
* @param page - logical page info object (`PdfPageObject`)
|
|
555
|
+
* @param annotationPtr - pointer to the annotation whose ink list is needed
|
|
556
|
+
* @returns ink list
|
|
557
|
+
*/
|
|
558
|
+
private getInkList;
|
|
559
|
+
/**
|
|
560
|
+
* Add ink list to annotation
|
|
561
|
+
* @param page - logical page info object (`PdfPageObject`)
|
|
562
|
+
* @param annotationPtr - pointer to the annotation whose ink list is needed
|
|
563
|
+
* @param annotation - annotation object (`PdfInkAnnoObject`)
|
|
564
|
+
* @returns `true` if the operation was successful
|
|
565
|
+
*/
|
|
566
|
+
private setInkList;
|
|
548
567
|
/**
|
|
549
568
|
* Read pdf text annotation
|
|
550
569
|
* @param page - pdf page infor
|
|
@@ -763,6 +782,25 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
763
782
|
* @private
|
|
764
783
|
*/
|
|
765
784
|
private readPdfPageObjectTransformMatrix;
|
|
785
|
+
/**
|
|
786
|
+
* Return the stroke-width declared in the annotation’s /Border or /BS entry.
|
|
787
|
+
* Falls back to 1 pt when nothing is defined.
|
|
788
|
+
*
|
|
789
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
790
|
+
* @returns stroke-width
|
|
791
|
+
*
|
|
792
|
+
* @private
|
|
793
|
+
*/
|
|
794
|
+
private getStrokeWidth;
|
|
795
|
+
/**
|
|
796
|
+
* Fetches the `/F` flag bit-field from an annotation.
|
|
797
|
+
*
|
|
798
|
+
* @param annotationPtr pointer to an `FPDF_ANNOTATION`
|
|
799
|
+
* @returns `{ raw, flags }`
|
|
800
|
+
* • `raw` – the 32-bit integer returned by PDFium
|
|
801
|
+
* • `flags` – object with individual booleans
|
|
802
|
+
*/
|
|
803
|
+
private getAnnotationFlags;
|
|
766
804
|
/**
|
|
767
805
|
* Read circle annotation
|
|
768
806
|
* @param page - pdf page infor
|
|
@@ -852,6 +890,13 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
852
890
|
* @private
|
|
853
891
|
*/
|
|
854
892
|
private readPdfWidgetAnnoField;
|
|
893
|
+
/**
|
|
894
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.renderAnnotation}
|
|
895
|
+
*
|
|
896
|
+
* @public
|
|
897
|
+
*/
|
|
898
|
+
renderAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, scaleFactor: number, rotation: Rotation, dpr?: number, // device-pixel-ratio (canvas)
|
|
899
|
+
mode?: AppearanceMode, imageType?: ImageConversionTypes): PdfTask<T>;
|
|
855
900
|
/**
|
|
856
901
|
* render rectangle of pdf page to image
|
|
857
902
|
* @param docPtr - pointer to pdf document object
|