@embedpdf/engines 1.0.5 → 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/pdfium.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SearchTarget, PdfImage, ImageConversionTypes, PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, PdfTask, Rect, PdfAnnotationObject, PdfAnnotationTransformation, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PdfInkListObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, MatchFlag, SearchAllPagesResult, PdfEngineMethodName, PdfEngineMethodArgs, TaskReturn, PdfEngineMethodReturnType } from '@embedpdf/models';
1
+ import { SearchTarget, PdfImage, ImageConversionTypes, PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, PdfTask, Rect, PdfAnnotationObject, PdfAnnotationTransformation, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PageTextSlice, PdfInkListObject, PdfHighlightAnnoObject, PdfUnderlineAnnoObject, PdfStrikeOutAnnoObject, PdfSquigglyAnnoObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, PdfAnnotationObjectBase, WebAlphaColor, MatchFlag, SearchAllPagesResult, PdfEngineMethodName, PdfEngineMethodArgs, TaskReturn, PdfEngineMethodReturnType } from '@embedpdf/models';
2
2
  import { WrappedPdfiumModule, PdfiumRuntimeMethods, PdfiumModule } from '@embedpdf/pdfium';
3
3
 
4
4
  /**
@@ -208,7 +208,17 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
208
208
  *
209
209
  * @public
210
210
  */
211
- createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
211
+ createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<number>;
212
+ /**
213
+ * Update an existing page annotation in-place
214
+ *
215
+ * • Locates the annot by page-local index (`annotation.id`)
216
+ * • Re-writes its /Rect and type-specific payload
217
+ * • Calls FPDFPage_GenerateContent so the new appearance is rendered
218
+ *
219
+ * @returns PdfTask<boolean> – true on success
220
+ */
221
+ updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
212
222
  /**
213
223
  * {@inheritDoc @embedpdf/models!PdfEngine.transformPageAnnotation}
214
224
  *
@@ -269,6 +279,12 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
269
279
  * @public
270
280
  */
271
281
  extractText(doc: PdfDocumentObject, pageIndexes: number[]): Task<any, PdfErrorReason> | Task<string, PdfErrorReason>;
282
+ /**
283
+ * {@inheritDoc @embedpdf/models!PdfEngine.getTextSlices}
284
+ *
285
+ * @public
286
+ */
287
+ getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): PdfTask<string[]>;
272
288
  /**
273
289
  * {@inheritDoc @embedpdf/models!PdfEngine.merge}
274
290
  *
@@ -324,6 +340,16 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
324
340
  * @private
325
341
  */
326
342
  addInkStroke(page: PdfPageObject, pagePtr: number, annotationPtr: number, inkList: PdfInkListObject[]): boolean;
343
+ /**
344
+ * Add highlight content to annotation
345
+ * @param page - page info
346
+ * @param annotationPtr - pointer to highlight annotation
347
+ * @param annotation - highlight annotation
348
+ * @returns whether highlight content is added to annotation
349
+ *
350
+ * @private
351
+ */
352
+ addTextMarkupContent(page: PdfPageObject, annotationPtr: number, annotation: PdfHighlightAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfSquigglyAnnoObject, shouldClearAP?: boolean): boolean;
327
353
  /**
328
354
  * Add contents to stamp annotation
329
355
  * @param docPtr - pointer to pdf document object
@@ -531,11 +557,23 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
531
557
  *
532
558
  * @param annotationPtr - pointer to an `FPDF_ANNOTATION`
533
559
  * @param fallback - colour to use when the PDF stores no tint at all
534
- * @returns Guaranteed RGBA tuple (never `undefined`)
560
+ * @returns WebAlphaColor with hex color and opacity (0-1)
535
561
  *
536
562
  * @private
537
563
  */
538
564
  private resolveAnnotationColor;
565
+ /**
566
+ * Set the fill/stroke colour for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
567
+ *
568
+ * @param annotationPtr - pointer to the annotation whose colour is being set
569
+ * @param webAlphaColor - WebAlphaColor with hex color and opacity (0-1)
570
+ * @param shouldClearAP - whether to clear the /AP entry
571
+ * @param which - which colour to set (0 = fill, 1 = stroke)
572
+ * @returns `true` if the operation was successful
573
+ *
574
+ * @private
575
+ */
576
+ private setAnnotationColor;
539
577
  /**
540
578
  * Read `/QuadPoints` from any annotation and convert each quadrilateral to
541
579
  * device-space coordinates.
@@ -547,11 +585,22 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
547
585
  *
548
586
  * @param page - logical page info object (`PdfPageObject`)
549
587
  * @param annotationPtr - pointer to the annotation whose quads are needed
550
- * @returns Array of `Quad` objects (`[]` if the annotation has no quads)
588
+ * @returns Array of `Rect` objects (`[]` if the annotation has no quads)
589
+ *
590
+ * @private
591
+ */
592
+ private getQuadPointsAnno;
593
+ /**
594
+ * Set the quadrilaterals for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
595
+ *
596
+ * @param page - logical page info object (`PdfPageObject`)
597
+ * @param annotationPtr - pointer to the annotation whose quads are needed
598
+ * @param rects - array of `Rect` objects (`[]` if the annotation has no quads)
599
+ * @returns `true` if the operation was successful
551
600
  *
552
601
  * @private
553
602
  */
554
- private readAnnotationQuads;
603
+ private syncQuadPointsAnno;
555
604
  /**
556
605
  * Read pdf text annotation
557
606
  * @param page - pdf page infor
@@ -814,14 +863,6 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
814
863
  * @private
815
864
  */
816
865
  private getInReplyToId;
817
- /**
818
- * Parse a PDF date string **D:YYYYMMDDHHmmSSOHH'mm'** to ISO-8601.
819
- *
820
- * Returns `undefined` if the input is malformed.
821
- *
822
- * @private
823
- */
824
- private toIsoDate;
825
866
  /**
826
867
  * Fetch a string value (`/T`, `/M`, `/State`, …) from an annotation.
827
868
  *
@@ -831,16 +872,13 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
831
872
  */
832
873
  private getAnnotString;
833
874
  /**
834
- * Read linked popup of pdf annotation
835
- * @param page - pdf page infor
836
- * @param pagePtr - pointer to pdf page object
837
- * @param annotationPtr - pointer to pdf annotation
838
- * @param index - index of annotation in the pdf page
839
- * @returns pdf popup linked to annotation
875
+ * Set a string value (`/T`, `/M`, `/State`, …) to an annotation.
876
+ *
877
+ * @returns `true` if the operation was successful
840
878
  *
841
879
  * @private
842
880
  */
843
- private readPdfAnnoLinkedPopup;
881
+ private setAnnotString;
844
882
  /**
845
883
  * Read vertices of pdf annotation
846
884
  * @param page - pdf page infor
@@ -966,6 +1004,23 @@ declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
966
1004
  * @private
967
1005
  */
968
1006
  private readPageAnnoAppearanceStream;
1007
+ /**
1008
+ * Change the visible colour (and opacity) of an existing annotation.
1009
+ *
1010
+ * For markup annotations (highlight / underline / strikeout / squiggly) we
1011
+ * first clear the AP dictionary entry, otherwise the stored appearance stream
1012
+ * will override the new tint. For all other sub-types we keep the existing
1013
+ * AP so custom artwork isn't lost.
1014
+ *
1015
+ * @param doc logical document object
1016
+ * @param page logical page object
1017
+ * @param annotation the annotation we want to recolour
1018
+ * @param colour RGBA tuple (0-255 per channel)
1019
+ * @param which 0 = stroke/fill colour (PDFium's "colourType" param)
1020
+ *
1021
+ * @returns `true` when the operation succeeded
1022
+ */
1023
+ updateAnnotationColor(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number): PdfTask<boolean>;
969
1024
  /**
970
1025
  * Set the rect of specified annotation
971
1026
  * @param page - page info that the annotation is belonged to