@embedpdf/engines 1.0.6 → 1.0.7
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 +368 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +72 -21
- package/dist/index.js +369 -185
- package/dist/index.js.map +1 -1
- package/dist/pdfium-direct-engine.cjs +325 -177
- package/dist/pdfium-direct-engine.cjs.map +1 -1
- package/dist/pdfium-direct-engine.d.ts +69 -20
- package/dist/pdfium-direct-engine.js +326 -178
- package/dist/pdfium-direct-engine.js.map +1 -1
- package/dist/pdfium-worker-engine.cjs +31 -1
- package/dist/pdfium-worker-engine.cjs.map +1 -1
- package/dist/pdfium-worker-engine.d.ts +4 -2
- package/dist/pdfium-worker-engine.js +31 -1
- package/dist/pdfium-worker-engine.js.map +1 -1
- package/dist/pdfium.cjs +332 -178
- package/dist/pdfium.cjs.map +1 -1
- package/dist/pdfium.d.ts +69 -20
- package/dist/pdfium.js +333 -179
- package/dist/pdfium.js.map +1 -1
- package/dist/worker.cjs +30 -0
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +4 -2
- package/dist/worker.js +30 -0
- 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, PdfAnnotationTransformation, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PageTextSlice, PdfInkListObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, MatchFlag, SearchAllPagesResult, PdfImage } from '@embedpdf/models';
|
|
1
|
+
import { PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, ImageConversionTypes, PdfTask, Rect, PdfAnnotationObject, PdfAnnotationTransformation, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PageTextSlice, PdfInkListObject, PdfHighlightAnnoObject, PdfUnderlineAnnoObject, PdfStrikeOutAnnoObject, PdfSquigglyAnnoObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, PdfAnnotationObjectBase, WebAlphaColor, MatchFlag, SearchAllPagesResult, PdfImage } from '@embedpdf/models';
|
|
2
2
|
import { WrappedPdfiumModule } from '@embedpdf/pdfium';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -152,7 +152,17 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
152
152
|
*
|
|
153
153
|
* @public
|
|
154
154
|
*/
|
|
155
|
-
createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject):
|
|
155
|
+
createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<number>;
|
|
156
|
+
/**
|
|
157
|
+
* Update an existing page annotation in-place
|
|
158
|
+
*
|
|
159
|
+
* • Locates the annot by page-local index (`annotation.id`)
|
|
160
|
+
* • Re-writes its /Rect and type-specific payload
|
|
161
|
+
* • Calls FPDFPage_GenerateContent so the new appearance is rendered
|
|
162
|
+
*
|
|
163
|
+
* @returns PdfTask<boolean> – true on success
|
|
164
|
+
*/
|
|
165
|
+
updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
|
|
156
166
|
/**
|
|
157
167
|
* {@inheritDoc @embedpdf/models!PdfEngine.transformPageAnnotation}
|
|
158
168
|
*
|
|
@@ -274,6 +284,16 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
274
284
|
* @private
|
|
275
285
|
*/
|
|
276
286
|
addInkStroke(page: PdfPageObject, pagePtr: number, annotationPtr: number, inkList: PdfInkListObject[]): boolean;
|
|
287
|
+
/**
|
|
288
|
+
* Add highlight content to annotation
|
|
289
|
+
* @param page - page info
|
|
290
|
+
* @param annotationPtr - pointer to highlight annotation
|
|
291
|
+
* @param annotation - highlight annotation
|
|
292
|
+
* @returns whether highlight content is added to annotation
|
|
293
|
+
*
|
|
294
|
+
* @private
|
|
295
|
+
*/
|
|
296
|
+
addTextMarkupContent(page: PdfPageObject, annotationPtr: number, annotation: PdfHighlightAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfSquigglyAnnoObject, shouldClearAP?: boolean): boolean;
|
|
277
297
|
/**
|
|
278
298
|
* Add contents to stamp annotation
|
|
279
299
|
* @param docPtr - pointer to pdf document object
|
|
@@ -481,11 +501,23 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
481
501
|
*
|
|
482
502
|
* @param annotationPtr - pointer to an `FPDF_ANNOTATION`
|
|
483
503
|
* @param fallback - colour to use when the PDF stores no tint at all
|
|
484
|
-
* @returns
|
|
504
|
+
* @returns WebAlphaColor with hex color and opacity (0-1)
|
|
485
505
|
*
|
|
486
506
|
* @private
|
|
487
507
|
*/
|
|
488
508
|
private resolveAnnotationColor;
|
|
509
|
+
/**
|
|
510
|
+
* Set the fill/stroke colour for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
|
|
511
|
+
*
|
|
512
|
+
* @param annotationPtr - pointer to the annotation whose colour is being set
|
|
513
|
+
* @param webAlphaColor - WebAlphaColor with hex color and opacity (0-1)
|
|
514
|
+
* @param shouldClearAP - whether to clear the /AP entry
|
|
515
|
+
* @param which - which colour to set (0 = fill, 1 = stroke)
|
|
516
|
+
* @returns `true` if the operation was successful
|
|
517
|
+
*
|
|
518
|
+
* @private
|
|
519
|
+
*/
|
|
520
|
+
private setAnnotationColor;
|
|
489
521
|
/**
|
|
490
522
|
* Read `/QuadPoints` from any annotation and convert each quadrilateral to
|
|
491
523
|
* device-space coordinates.
|
|
@@ -497,11 +529,22 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
497
529
|
*
|
|
498
530
|
* @param page - logical page info object (`PdfPageObject`)
|
|
499
531
|
* @param annotationPtr - pointer to the annotation whose quads are needed
|
|
500
|
-
* @returns Array of `
|
|
532
|
+
* @returns Array of `Rect` objects (`[]` if the annotation has no quads)
|
|
533
|
+
*
|
|
534
|
+
* @private
|
|
535
|
+
*/
|
|
536
|
+
private getQuadPointsAnno;
|
|
537
|
+
/**
|
|
538
|
+
* Set the quadrilaterals for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
|
|
539
|
+
*
|
|
540
|
+
* @param page - logical page info object (`PdfPageObject`)
|
|
541
|
+
* @param annotationPtr - pointer to the annotation whose quads are needed
|
|
542
|
+
* @param rects - array of `Rect` objects (`[]` if the annotation has no quads)
|
|
543
|
+
* @returns `true` if the operation was successful
|
|
501
544
|
*
|
|
502
545
|
* @private
|
|
503
546
|
*/
|
|
504
|
-
private
|
|
547
|
+
private syncQuadPointsAnno;
|
|
505
548
|
/**
|
|
506
549
|
* Read pdf text annotation
|
|
507
550
|
* @param page - pdf page infor
|
|
@@ -764,14 +807,6 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
764
807
|
* @private
|
|
765
808
|
*/
|
|
766
809
|
private getInReplyToId;
|
|
767
|
-
/**
|
|
768
|
-
* Parse a PDF date string **D:YYYYMMDDHHmmSSOHH'mm'** to ISO-8601.
|
|
769
|
-
*
|
|
770
|
-
* Returns `undefined` if the input is malformed.
|
|
771
|
-
*
|
|
772
|
-
* @private
|
|
773
|
-
*/
|
|
774
|
-
private toIsoDate;
|
|
775
810
|
/**
|
|
776
811
|
* Fetch a string value (`/T`, `/M`, `/State`, …) from an annotation.
|
|
777
812
|
*
|
|
@@ -781,16 +816,13 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
781
816
|
*/
|
|
782
817
|
private getAnnotString;
|
|
783
818
|
/**
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
* @
|
|
787
|
-
* @param annotationPtr - pointer to pdf annotation
|
|
788
|
-
* @param index - index of annotation in the pdf page
|
|
789
|
-
* @returns pdf popup linked to annotation
|
|
819
|
+
* Set a string value (`/T`, `/M`, `/State`, …) to an annotation.
|
|
820
|
+
*
|
|
821
|
+
* @returns `true` if the operation was successful
|
|
790
822
|
*
|
|
791
823
|
* @private
|
|
792
824
|
*/
|
|
793
|
-
private
|
|
825
|
+
private setAnnotString;
|
|
794
826
|
/**
|
|
795
827
|
* Read vertices of pdf annotation
|
|
796
828
|
* @param page - pdf page infor
|
|
@@ -916,6 +948,23 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
|
916
948
|
* @private
|
|
917
949
|
*/
|
|
918
950
|
private readPageAnnoAppearanceStream;
|
|
951
|
+
/**
|
|
952
|
+
* Change the visible colour (and opacity) of an existing annotation.
|
|
953
|
+
*
|
|
954
|
+
* For markup annotations (highlight / underline / strikeout / squiggly) we
|
|
955
|
+
* first clear the AP dictionary entry, otherwise the stored appearance stream
|
|
956
|
+
* will override the new tint. For all other sub-types we keep the existing
|
|
957
|
+
* AP so custom artwork isn't lost.
|
|
958
|
+
*
|
|
959
|
+
* @param doc logical document object
|
|
960
|
+
* @param page logical page object
|
|
961
|
+
* @param annotation the annotation we want to recolour
|
|
962
|
+
* @param colour RGBA tuple (0-255 per channel)
|
|
963
|
+
* @param which 0 = stroke/fill colour (PDFium's "colourType" param)
|
|
964
|
+
*
|
|
965
|
+
* @returns `true` when the operation succeeded
|
|
966
|
+
*/
|
|
967
|
+
updateAnnotationColor(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number): PdfTask<boolean>;
|
|
919
968
|
/**
|
|
920
969
|
* Set the rect of specified annotation
|
|
921
970
|
* @param page - page info that the annotation is belonged to
|