diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-event.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-event.md index edecf4606..828fc6624 100644 --- a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-event.md +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-event.md @@ -112,11 +112,11 @@ export default App; ### annotationDoubleClick -The [annotationDoubleClick](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationdoubleclickevent) event is triggered when an annotation is double-clicked. +The [annotationDoubleClick](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationdoubleclickevent) event is triggered when an annotation is double-clicked. #### Event Arguments -For event data, see [AnnotationDoubleClickEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationDoubleClickEventArgs/). +For event data, see [AnnotationDoubleClickEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationDoubleClickEventArgs). The following example illustrates how to handle the `annotationDoubleClick` event. @@ -187,11 +187,11 @@ export default App; ### annotationMouseLeave -The [annotationMouseLeave](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationmouseleaveevent) event is triggered when the user's mouse pointer moves away from an annotation object. +The [annotationMouseLeave](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#annotationmouseleave) event is triggered when the user's mouse pointer moves away from an annotation object. #### Event Arguments -For event data, see [AnnotationMouseLeaveEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMouseLeaveEventArgs/). +For event data, see [AnnotationMouseLeaveEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMouseLeaveEventArgs). The following example illustrates how to handle the `annotationMouseLeave` event. @@ -262,11 +262,11 @@ export default App; ### annotationMouseover -The [annotationMouseover](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationmouseoverevent) event is triggered when the mouse is moved over an annotation object. +The [annotationMouseover](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationmouseoverevent) event is triggered when the mouse is moved over an annotation object. #### Event Arguments -For event data, see [AnnotationMouseOverEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMouseOverEventArgs/). +For event data, see [AnnotationMouseOverEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMouseOverEventArgs). The following example illustrates how to handle the `annotationMouseover` event. @@ -337,11 +337,11 @@ export default App; ### annotationMove -The [annotationMove](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationmoveevent) event is triggered when an annotation is moved over the page of the PDF document. +The [annotationMove](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationmoveevent) event is triggered when an annotation is moved over the page of the PDF document. #### Event Arguments -For event data, see [AnnotationMoveEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMoveEventArgs/). +For event data, see [AnnotationMoveEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMoveEventArgs). The following example illustrates how to handle the `annotationMove` event. @@ -412,11 +412,11 @@ export default App; ### annotationMoving -The [annotationMoving](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationmovingevent) event is triggered while an annotation is being moved. +The [annotationMoving](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationmovingevent) event is triggered while an annotation is being moved. #### Event Arguments -For event data, see [AnnotationMovingEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMovingEventArgs/). +For event data, see [AnnotationMovingEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationMovingEventArgs). The following example illustrates how to handle the `annotationMoving` event. @@ -487,11 +487,11 @@ export default App; ### annotationPropertiesChange -The [annotationPropertiesChange](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationpropertieschangeevent) event is triggered when an annotation's property is modified on a PDF document page. +The [annotationPropertiesChange](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationpropertieschangeevent) event is triggered when an annotation's property is modified on a PDF document page. #### Event Arguments -For event data, see [AnnotationPropertiesChangeEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationPropertiesChangeEventArgs/). It provides properties such as `annotationId`, `pageNumber`, and `action`. +For event data, see [AnnotationPropertiesChangeEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationPropertiesChangeEventArgs). It provides properties such as `annotationId`, `pageNumber`, and `action`. The following example illustrates how to handle the `annotationPropertiesChange` event. @@ -563,11 +563,11 @@ export default App; ### annotationRemove -The [annotationRemove](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationremoveevent) event is triggered when an annotation is removed from a PDF document's page. +The [annotationRemove](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationremoveevent) event is triggered when an annotation is removed from a PDF document's page. #### Event Arguments -For event data, see [AnnotationRemoveEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationRemoveEventArgs/). It provides properties such as `annotationId` and `pageNumber`. +For event data, see [AnnotationRemoveEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationRemoveEventArgs). It provides properties such as `annotationId` and `pageNumber`. The following example illustrates how to handle the `annotationRemove` event. @@ -638,11 +638,11 @@ export default App; ### annotationResize -The [annotationResize](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationresizeevent) event is triggered when an annotation is resized on a PDF document page. +The [annotationResize](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationresizeevent) event is triggered when an annotation is resized on a PDF document page. #### Event Arguments -For event data, see [AnnotationResizeEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationResizeEventArgs/). +For event data, see [AnnotationResizeEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationResizeEventArgs). The following example illustrates how to handle the `annotationResize` event. @@ -713,11 +713,11 @@ export default App; ### annotationSelect -The [annotationSelect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationselectevent) event is triggered when an annotation is selected on a PDF document's page. +The [annotationSelect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationselectevent) event is triggered when an annotation is selected on a PDF document's page. #### Event Arguments -For event data, see [AnnotationSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationSelectEventArgs/). +For event data, see [AnnotationSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationSelectEventArgs). The following example illustrates how to handle the `annotationSelect` event. @@ -788,11 +788,11 @@ export default App; ### annotationUnselect -The [annotationUnselect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#annotationunselectevent) event is triggered when an annotation is unselected from the PDF document's page. +The [annotationUnselect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#annotationunselectevent) event is triggered when an annotation is unselected from the PDF document's page. #### Event Arguments -For event data, see [AnnotationUnSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationUnSelectEventArgs/). +For event data, see [AnnotationUnSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/annotationUnSelectEventArgs). The following example illustrates how to handle the `annotationUnselect` event. @@ -863,11 +863,11 @@ export default App; ### beforeAddFreeText -The [beforeAddFreeText](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#beforeaddfreetextevent) event is triggered before adding a text in the freeText annotation. +The [beforeAddFreeText](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#beforeaddfreetextevent) event is triggered before adding a text in the freeText annotation. #### Event Arguments -For event data, see [BeforeAddFreeTextEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/beforeAddFreeTextEventArgs/). +For event data, see [BeforeAddFreeTextEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/beforeAddFreeTextEventArgs). The following example illustrates how to handle the `beforeAddFreeText` event. @@ -942,11 +942,11 @@ export default App; ### addSignature -The [addSignature](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#addsignatureevent) event is triggered when a signature is added to a page of a PDF document. +The [addSignature](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#addsignatureevent) event is triggered when a signature is added to a page of a PDF document. #### Event Arguments -For event data, see [AddSignatureEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/addSignatureEventArgs/). It provides properties such as `pageNumber`. +For event data, see [AddSignatureEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/addSignatureEventArgs). It provides properties such as `pageNumber`. The following example illustrates how to handle the `addSignature` event. @@ -1017,11 +1017,11 @@ export default App; ### removeSignature -The [removeSignature](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#removesignatureevent) event is triggered when the signature is removed from the page of a PDF document. +The [removeSignature](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#removesignatureevent) event is triggered when the signature is removed from the page of a PDF document. #### Event Arguments -For event data, see [RemoveSignatureEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/removeSignatureEventArgs/). It provides properties such as `pageNumber`. +For event data, see [RemoveSignatureEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/removeSignatureEventArgs). It provides properties such as `pageNumber`. The following example illustrates how to handle the `removeSignature` event. @@ -1092,11 +1092,11 @@ export default App; ### resizeSignature -The [resizeSignature](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#resizesignatureevent) event is triggered when the signature is resized and placed on a page of a PDF document. +The [resizeSignature](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#resizesignatureevent) event is triggered when the signature is resized and placed on a page of a PDF document. #### Event Arguments -For event data, see [ResizeSignatureEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/resizeSignatureEventArgs/). +For event data, see [ResizeSignatureEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/resizeSignatureEventArgs). The following example illustrates how to handle the `resizeSignature` event. @@ -1167,11 +1167,11 @@ export default App; ### signaturePropertiesChange -The [signaturePropertiesChange](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#signaturepropertieschangeevent) event is triggered when the property of the signature is changed in the page of the PDF document. +The [signaturePropertiesChange](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#signaturepropertieschangeevent) event is triggered when the property of the signature is changed in the page of the PDF document. #### Event Arguments -For event data, see [SignaturePropertiesChangeEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/signaturePropertiesChangeEventArgs/). +For event data, see [SignaturePropertiesChangeEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/signaturePropertiesChangeEventArgs). The following example illustrates how to handle the `signaturePropertiesChange` event. @@ -1242,11 +1242,11 @@ export default App; ### signatureSelect -The [signatureSelect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#signatureselectevent) event is triggered when signature is selected over the page of the PDF document. +The [signatureSelect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#signatureselectevent) event is triggered when signature is selected over the page of the PDF document. #### Event Arguments -For event data, see [SignatureSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/signatureSelectEventArgs/). +For event data, see [SignatureSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/signatureSelectEventArgs). The following example illustrates how to handle the `signatureSelect` event. @@ -1317,11 +1317,11 @@ export default App; ### signatureUnselect -The [signatureUnselect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/#signatureunselectevent) event is triggered when signature is unselected over the page of the PDF document. +The [signatureUnselect](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#signatureunselectevent) event is triggered when signature is unselected over the page of the PDF document. #### Event Arguments -For event data, see [SignatureUnSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/signatureUnSelectEventArgs/). +For event data, see [SignatureUnSelectEventArgs](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/signatureUnSelectEventArgs). The following example illustrates how to handle the `signatureUnselect` event. diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/annotation-undo-redo.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/annotation-undo-redo.png new file mode 100644 index 000000000..fe93c32f7 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/annotation-undo-redo.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/area-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/area-annot.png new file mode 100644 index 000000000..5974cf3bc Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/area-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/arrow-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/arrow-annot.png new file mode 100644 index 000000000..c85e14482 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/arrow-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/circle-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/circle-annot.png new file mode 100644 index 000000000..25eb71e63 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/circle-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/delete-annot-context-menu.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/delete-annot-context-menu.png new file mode 100644 index 000000000..7a622d4ac Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/delete-annot-context-menu.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/delete-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/delete-annot.png new file mode 100644 index 000000000..11a148f2f Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/delete-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/distance-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/distance-annot.png new file mode 100644 index 000000000..9adddffc2 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/distance-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/export-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/export-annot.png new file mode 100644 index 000000000..9ad0f027e Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/export-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/free-text-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/free-text-annot.png new file mode 100644 index 000000000..9b5ab0fb6 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/free-text-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/highlight-context.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/highlight-context.gif new file mode 100644 index 000000000..205b0ec3b Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/highlight-context.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/highlight-tool.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/highlight-tool.gif new file mode 100644 index 000000000..bb780e81e Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/highlight-tool.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/import-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/import-annot.png new file mode 100644 index 000000000..8921a81c3 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/import-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/line-angle-constraint.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/line-angle-constraint.gif new file mode 100644 index 000000000..12ca903df Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/line-angle-constraint.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/line-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/line-annot.png new file mode 100644 index 000000000..691212636 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/line-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/perimeter-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/perimeter-annot.png new file mode 100644 index 000000000..6f97c31e0 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/perimeter-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/polygon-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/polygon-annot.png new file mode 100644 index 000000000..38318eaf6 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/polygon-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/radius-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/radius-annot.png new file mode 100644 index 000000000..b04dcfbee Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/radius-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/rect-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/rect-annot.png new file mode 100644 index 000000000..36e5305f9 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/rect-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/squiggle-context.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/squiggle-context.gif new file mode 100644 index 000000000..cc1d2ea21 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/squiggle-context.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/squiggle-tool.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/squiggle-tool.gif new file mode 100644 index 000000000..bc5e01966 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/squiggle-tool.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/strikethrough-context.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/strikethrough-context.gif new file mode 100644 index 000000000..a1bc4f77d Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/strikethrough-context.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/strikethrough-tool.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/strikethrough-tool.gif new file mode 100644 index 000000000..bd482b495 Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/strikethrough-tool.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/underline-context.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/underline-context.gif new file mode 100644 index 000000000..e06278e5b Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/underline-context.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/underline-tool.gif b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/underline-tool.gif new file mode 100644 index 000000000..f274f11bb Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/underline-tool.gif differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/volume-annot.png b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/volume-annot.png new file mode 100644 index 000000000..21387faca Binary files /dev/null and b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-images/volume-annot.png differ diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-permission.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-permission.md new file mode 100644 index 000000000..0207a94cb --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-permission.md @@ -0,0 +1,112 @@ +--- +layout: post +title: Annotations Permission in React PDF Viewer | Syncfusion +description: Learn how to use annotation permissions in Syncfusion React PDF Viewer using programmatic APIs. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Annotation permissions in React PDF Viewer + +Use [annotationSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationsettings) to control creation-time permissions and behavior of annotations in the PDF Viewer. + +## Common permissions + +- isLock: Locks the annotation so it cannot be moved, resized, edited, or deleted. +- skipPrint: Excludes annotations from the print output when the document is printed from the viewer. +- skipDownload: Excludes annotations from the exported/downloaded document. + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, TextSearch, Print, Annotation, FormFields, FormDesigner, + AllowedInteraction} from '@syncfusion/ej2-pdfviewer'; + + PdfViewer.Inject(Toolbar,Magnification,Navigation, LinkAnnotation,ThumbnailView,BookmarkView, + TextSelection, TextSearch, Print, Annotation,FormFields, FormDesigner); + +let viewer: PdfViewer = new PdfViewer(); +viewer.resourceUrl= 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +viewer.documentPath= 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +// Default annotation settings applied to annotations created via the UI +viewer.annotationSettings = { + author: 'XYZ', + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, // allow moving/resizing/editing by default + skipPrint: false, // include annotations when printing the document + skipDownload: false, // include annotations when downloading/exporting the document + allowedInteractions: [AllowedInteraction.Resize], +}; + +viewer.appendTo("#pdfViewer"); +``` + +## Individual permissions + +- isPrint: Controls whether a specific annotation participates in printing. Set to false to prevent just that annotation from printing. +- isLock: You can also lock/unlock a specific annotation instance programmatically. + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +const pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib", + // Text markup defaults + highlightSettings: { author: 'QA', subject: 'Review', color: '#ffff00', opacity: 0.6 }, + strikethroughSettings: { author: 'QA', subject: 'Remove', color: '#ff0000', opacity: 0.6 }, + underlineSettings: { author: 'Guest User', subject: 'Points to be remembered', color: '#00ffff', opacity: 0.9 }, + squigglySettings: { author: 'Guest User', subject: 'Corrections', color: '#00ff00', opacity: 0.9 }, + + // Shapes + lineSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, isLock: false, isPrint: true }, + arrowSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, isLock: false, isPrint: true }, + rectangleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1, isLock: false, isPrint: true }, + circleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1, isLock: false, isPrint: true }, + polygonSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1, isLock: false, isPrint: true }, + + // Measurements + distanceSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, isLock: false, isPrint: true }, + perimeterSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, isLock: false, isPrint: true }, + areaSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00', isLock: false, isPrint: true }, + radiusSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00', isLock: false, isPrint: true }, + volumeSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00', isLock: false, isPrint: true }, + + // Others + freeTextSettings: { borderColor: '#222222', opacity: 1, isLock: false, isPrint: true }, + inkAnnotationSettings: { strokeColor: '#0000ff', thickness: 3, opacity: 0.8, isLock: false, isPrint: true }, + stampSettings: { opacity: 0.9, isLock: false, isPrint: true }, + stickyNotesSettings: { author: 'QA', subject: 'Review', opacity: 1, isLock: false, isPrint: true } +}); + +pdfviewer.appendTo('#PdfViewer'); +``` + +Behavior notes +- isLock true: The annotation is locked; users cannot move, resize, or edit it through the UI until it is unlocked. +- skipPrint true: All annotations are omitted from the print output initiated from the viewer. +- skipDownload true: All annotations are omitted from the exported/downloaded PDF from the viewer. +- isPrint on an individual annotation: Use this when you only want to exclude a particular annotation from printing while leaving others printable. + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../annotations/create-modify-annotation) +- [Customize Annotation](../annotations/customize-annotation) +- [Remove Annotation](../annotations/delete-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation API](../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/area-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/area-annotation.md new file mode 100644 index 000000000..8edee1f16 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/area-annotation.md @@ -0,0 +1,664 @@ +--- +layout: post +title: Area annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Area measurement annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Area annotation in React PDF Viewer + +Area is a measurement annotation used to measure the surface of a closed region in the PDF. + +![Area annotations overview](../annotation-images/area-annot.png) + +## Add Area Annotation + +### Add area annotation via UI + +Use the annotation toolbar: +- Click the **Edit Annotation** button in the PDF Viewer toolbar. +- Click the **Measurement Annotation** dropdown. +- Choose **Area**, then draw the region on the page. + +N> When in pan mode, selecting a measurement annotation switches the viewer to text select mode. + +![Measurement toolbar](../../images/calibrate_tool.png) + +### Enable area mode + +The PDF Viewer library allows drawing measurement annotations programmatically after enabling area mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function areaMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Area'); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function areaMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Area'); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +### Add an area annotation programmatically + +The PDF Viewer library allows adding measurement annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addAreaAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Area', { + offset: { x: 200, y: 500 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 500 }, { x: 288, y: 499 }, { x: 289, y: 553 }, { x: 200, y: 500 } + ] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +// Server-Backed +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addAreaAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Area', { + offset: { x: 200, y: 500 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 500 }, { x: 288, y: 499 }, { x: 289, y: 553 }, { x: 200, y: 500 } + ] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Area Annotation + +### Edit Area Annotation in UI + +You can select, move, and resize Area annotations directly in the viewer: +- Select an Area to show its vertex handles. +- Move: drag inside the shape to reposition it on the page. +- Resize/reshape: drag any vertex handle to adjust the polygon points and size. +- Delete or access more options from the context menu. + +Use the toolbar to change appearance: +- Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools. + +See the sections below for screenshots and details. + +#### Edit the properties of area annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing area annotation programmatically + +To modify an existing area annotation programmatically, use the editAnnotation() method. + +Here is an example of using editAnnotation(): + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function editAreaAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Area calculation') { + ann.annotationSelectorSettings.resizerShape = 'Circle'; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function editAreaAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Area calculation') { + ann.annotationSelectorSettings.resizerShape = 'Circle'; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default area settings during initialization + +Set default [areaSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#areasettings) before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `AreaSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Area settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function addAreaWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Area', { + offset: { x: 200, y: 500 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 500 }, { x: 288, y: 499 }, { x: 289, y: 553 }, { x: 200, y: 500 } + ], + fillColor: 'yellow', + opacity: 0.6, + strokeColor: 'orange' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function addAreaWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Area', { + offset: { x: 200, y: 500 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 500 }, { x: 288, y: 499 }, { x: 289, y: 553 }, { x: 200, y: 500 } + ], + fillColor: 'yellow', + opacity: 0.6, + strokeColor: 'orange' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); +{% endhighlight %} +{% endtabs %} + +## Editing scale ratio and unit of the area measurement annotation + +The scale ratio and unit of measurement can be modified using the scale ratio option provided in the context menu of the PDF Viewer control. + + ![CalibrateScaleRatio](../../images/calibrate_scaleratio.png) + +The Units of measurements support for the measurement annotations in the PDF Viewer are + +* Inch +* Millimeter +* Centimeter +* Point +* Pica +* Feet + +![CalibrateScaleDialog](../../images/calibrate_scaledialog.png) + +## Setting default scale ratio settings during control initialization + +The properties of scale ratio for measurement annotation can be set before creating the control using ScaleRatioSettings as shown in the following code snippet, + + +{% tabs %} +{% highlight js tabtitle="Standalone" %} +{% raw %} + +import * as ReactDOM from 'react-dom'; +import * as React from 'react'; +import { PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, + BookmarkView, ThumbnailView, Print, TextSelection, TextSearch, Annotation, + FormFields, FormDesigner, PageOrganizer, Inject } from '@syncfusion/ej2-react-pdfviewer'; +let pdfviewer; + +function App() { + return (
+
+ { pdfviewer = scope; }} + id="container" + documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" + resourceUrl="https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib" + measurementSettings={{scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm'}} + style={{ 'height': '640px' }}> + + + +
+
); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endraw %} +{% endhighlight %} +{% highlight js tabtitle="Server-Backed" %} +{% raw %} + +import * as ReactDOM from 'react-dom'; +import * as React from 'react'; +import { PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, + BookmarkView, ThumbnailView, Print, TextSelection, TextSearch, Annotation, + FormFields, FormDesigner, PageOrganizer, Inject } from '@syncfusion/ej2-react-pdfviewer'; +let pdfviewer; + +function App() { + return (
+
+ { pdfviewer = scope; }} + id="container" + documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" + serviceUrl="https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer" + measurementSettings={{scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm'}} + style={{ 'height': '640px' }}> + + +
+
); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endraw %} +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/arrow-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/arrow-annotation.md new file mode 100644 index 000000000..3df524677 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/arrow-annotation.md @@ -0,0 +1,566 @@ +--- +layout: post +title: Arrow annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Arrow annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Arrow annotation in React PDF Viewer + +Arrow is a shape annotation used to point, direct attention, or indicate flow. Common use cases include callouts, direction markers, and connectors in technical reviews. + +![Arrow annotations overview](../annotation-images/arrow-annot.png) + +## Add Arrow Annotation + +### Add arrow annotation via UI + +Use the annotation toolbar: +- Click the **Edit Annotation** button in the PDF Viewer toolbar. +- Open the **Shape Annotation**** dropdown. +- Choose **Arrow**, then draw on the page. + +N> When in pan mode, selecting a shape annotation switches the viewer to text select mode. + +![Shape toolbar](../../images/shape_toolbar.png) + +### Enable arrow mode + +The PDF Viewer library allows drawing shape annotations programmatically after enabling arrow mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function arrowMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Arrow'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function arrowMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Arrow'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +### Add an arrow annotation programmatically + +The PDF Viewer library allows adding shape annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addArrowAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Arrow', { + offset: { x: 200, y: 370 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 370 }, { x: 350, y: 370 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addArrowAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Arrow', { + offset: { x: 200, y: 370 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 370 }, { x: 350, y: 370 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); +{% endhighlight %} +{% endtabs %} + +## Edit Arrow Annotation + +### Edit arrow annotation in UI + +You can select, move, and resize Arrow annotations directly in the viewer: +- Select an Arrow to show its handles. +- Move: drag inside the shape to reposition it on the page. +- Resize/reshape: drag start/end handles to adjust its length and direction. +- Delete or access more options from the context menu. + +#### Editing the properties of the arrow annotation + +The fill color, stroke color, thickness, and opacity of arrow shape annotations can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +##### Editing fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![Edit fill color for shapes](../..//images/shape_fillColor.png) + +#### Editing stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![Edit stroke color for shapes](../../images/shape_strokecolor.png) + +#### Editing thickness + +The thickness of the border of the annotation can be edited using the range slider provided in the Edit Thickness tool. + +![Edit thickness for shapes](../../images/shape_thickness.png) + +#### Editing opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![Edit opacity for shapes](../../images/shape_opacity.png) + +#### Editing the line properties + +Arrow annotations have additional options in the Line Properties window. Open it by right-clicking a line or arrow annotation and selecting Properties from the context menu. + +![Line properties dialog](../../images/shape_lineprty.png) + +### Edit an existing arrow annotation programmatically + +To modify an existing arrow annotation programmatically, use the editAnnotation() method. + +Here is an example of using editAnnotation(): + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function editArrowAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Arrow') { + ann.annotationSelectorSettings.resizerShape = 'Circle'; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function editArrowAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Arrow') { + ann.annotationSelectorSettings.resizerShape = 'Circle'; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default arrow settings during initialization + +Set default [arrowSettings](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#arrowsettings) before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `ArrowSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default arrow settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function addArrowWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Arrow', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }], + fillColor: '#ff1010ff', + strokeColor: '#fff000', + opacity: 0.9, + author: 'User 1', + thickness: 1 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + + function addArrowWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Arrow', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }], + fillColor: '#ff1010ff', + strokeColor: '#fff000', + opacity: 0.9, + author: 'User 1', + thickness: 1 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +N> In both [Arrow](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#arrowsettings) and [Line](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#linesettings) annotations Settings, the Fill Color option is available only when an arrowhead style is applied at the Start or End. If both Start and End arrowhead styles are set to None, lines do not support fill rendering and the Fill Color option remains disabled. + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/circle-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/circle-annotation.md new file mode 100644 index 000000000..5adf6d86a --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/circle-annotation.md @@ -0,0 +1,573 @@ +--- +layout: post +title: Circle annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Circle annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Circle annotation in React PDF Viewer + +Circle is a shape annotation used to highlight circular regions or draw emphasis bubbles. + +![Circle annotations overview](../annotation-images/circle-annot.png) + +## Add Circle Annotation + +### Add circle annotation via UI + +Use the annotation toolbar: +- Click the **Edit Annotation** button in the PDF Viewer toolbar. +- Open the **Shape Annotation** dropdown. +- Choose **Circle**, then draw on the page. + +N> When in pan mode, selecting a shape annotation switches the viewer to text select mode. + +![Shape toolbar](../../images/shape_toolbar.png) + +### Enable circle mode + +The PDF Viewer library allows drawing Circle annotations programmatically after enabling Circle mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function circleMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Circle'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function circleMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Circle'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit circle mode + +{% tabs %} +{% highlight ts tabtitle="Common" %} + +// Common (works for both Standalone and Server-Backed setups) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// In your component JSX, add: +// +`` + +{% endhighlight %} +{% endtabs %} + +### Add a circle annotation programmatically + +Add shape annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addCircleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Circle', { + offset: { x: 200, y: 620 }, + pageNumber: 1, + width: 90, + height: 90 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addCircleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Circle', { + offset: { x: 200, y: 620 }, + pageNumber: 1, + width: 90, + height: 90 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Circle Annotation + +### Edit circle annotation in UI + +You can select, move, and resize Circle annotations directly in the viewer: +- Select a Circle to show its handles. +- Move: drag inside the shape to reposition it on the page. +- Resize: drag the corner handles to adjust its diameter. +- Delete or access more options from the context menu. + +#### Editing the properties of the circle annotation + +The fill color, stroke color, thickness, and opacity of circle shape annotations can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +##### Editing fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![Edit fill color for shapes](../../images/shape_fillColor.png) + +##### Editing stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![Edit stroke color for shapes](../../images/shape_strokecolor.png) + +##### Editing thickness + +The thickness of the border of the annotation can be edited using the range slider provided in the Edit Thickness tool. + +![Edit thickness for shapes](../../images/shape_thickness.png) + +##### Editing opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![Edit opacity for shapes](../../images/shape_opacity.png) + +### Edit an existing circle annotation programmatically + +Use editAnnotation on items from annotationCollection. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editCircleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Circle') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editCircleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Circle') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default circle settings during initialization + +Set default [circleSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#circlesettings) before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `CircleSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Circle settings. +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addCircleWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Circle', { + offset: { x: 200, y: 480 }, + pageNumber: 1, + width: 150, + height: 75, + opacity: 0.5, + strokeColor: '#FF0000', + fillColor: '#000fff#', // (ensure valid hex; e.g., '#000fff' without trailing '#') + author: 'User1' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addCircleWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Circle', { + offset: { x: 200, y: 480 }, + pageNumber: 1, + width: 150, + height: 75, + opacity: 0.5, + strokeColor: '#FF0000', + fillColor: '#000fff#', // (ensure valid hex; e.g., '#000fff') + author: 'User1' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/distance-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/distance-annotation.md new file mode 100644 index 000000000..8243faf8d --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/distance-annotation.md @@ -0,0 +1,651 @@ +--- +layout: post +title: Distance annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Distance measurement annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Distance annotation in React PDF Viewer + +Distance is a measurement annotation used to measure the length between two points in the PDF. + +![Distance annotations overview](../annotation-images/distance-annot.png) + +## Add Distance Annotation + +### Add distance annotation via UI + +Use the annotation toolbar: +- Click the **Edit Annotation** button in the PDF Viewer toolbar. +- Open the **Measurement Annotation** dropdown. +- Choose **Distance**, then draw on the page. + +N> When in pan mode, selecting a measurement annotation switches the viewer to text select mode. + +![Measurement toolbar](../../images/calibrate_tool.png) + +### Enable distance mode + +The PDF Viewer component allows drawing Distance annotations programmatically after enabling Distance mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function distanceMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Distance'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function distanceMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Distance'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit distance mode + +{% tabs %} +{% highlight ts tabtitle="Common" %} + +// Common (works for both Standalone and Server-Backed) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// In your component JSX, add: +// + +{% endhighlight %} +{% endtabs %} + +### Add a distance annotation programmatically + +Add measurement annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addDistanceAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Distance', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addDistanceAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Distance', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Distance Annotation + +### Edit distance annotation in UI + +You can select, move, and resize Distance annotations directly in the viewer: +- Select a Distance measurement to show its handles. +- Move: drag the line to reposition it on the page. +- Resize: drag the end handles to adjust its length. +- Delete or access more options from the context menu. + +#### Edit the properties of area annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing distance annotation programmatically + +Use editAnnotation on items from annotationCollection. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editDistanceAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Distance calculation') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.opacity = 0.8; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editDistanceAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Distance calculation') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.opacity = 0.8; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default distance settings during initialization + +Set default [distanceSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#distancesettings) before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `DistanceSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Distance settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addDistanceWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Distance', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }], + fillColor: 'blue', + opacity: 0.6, + strokeColor: 'green' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addDistanceWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Distance', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }], + fillColor: 'blue', + opacity: 0.6, + strokeColor: 'green' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Scale ratio and units + +You can modify scale ratio and units using the Scale Ratio option in the context menu. + +![Scale ratio](../../images/calibrate_scaleratio.png) + +Supported units: +- Inch, Millimeter, Centimeter, Point, Pica, Feet + +![Scale dialog](../../images/calibrate_scaledialog.png) + +Set defaults via measurementSettings: + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/free-text-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/free-text-annotation.md new file mode 100644 index 000000000..19c782365 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/free-text-annotation.md @@ -0,0 +1,606 @@ +--- +layout: post +title: Free text annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and customize Free Text annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Free text annotation in React PDF Viewer + +Free Text is a text box annotation used to place formatted text anywhere on the page for notes, labels, or callouts. + +![Free text](../annotation-images/free-text-annot.png) + +## Add Free Text annotation + +### Add Free Text annotation via UI + +Use the annotation toolbar: +- Click the **Edit Annotation** button in the PDF Viewer toolbar. +- Click the **Free Text Annotation** button to enable Free Text mode. +- Click on the page to add text. + +When in pan mode, selecting Free Text switches the viewer to text select mode. + +![Free text tool in the annotation toolbar](../annotation-images/free-text-annot.png) + +### Switch to Free Text mode + +The PDF Viewer component allows drawing Distance annotations programmatically after enabling Distance mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function freeTextMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('FreeText'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function freeTextMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('FreeText'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +### Add Free Text annotation programmatically + +Use [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) to programmatically create Free Text. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addFreeTextProgram() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('FreeText', { + offset: { x: 120, y: 80 }, + pageNumber: 1, + width: 200, + height: 40, + fontSize: 16, + fontFamily: 'Helvetica', + isLock: false, + defaultText: 'Syncfusion' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addFreeTextProgram() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('FreeText', { + offset: { x: 120, y: 80 }, + pageNumber: 1, + width: 200, + height: 40, + fontSize: 16, + fontFamily: 'Helvetica', + isLock: false, + defaultText: 'Syncfusion' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Free Text annotation + +### Edit Free Text Annotation in UI + +You can select, move, and resize FreeText annotations directly in the viewer: +- Select a Free Text annotation to display its bounding box and resize handles. +- Move: drag the annotation box to reposition it on the page. +- Resize: drag any corner or edge handle to adjust its size. +- Delete: press the Delete key or use the context menu to remove the annotation. + +Use the toolbar to change the appearance of the selected Free Text annotation: +- Font Family, Font Size, Font Style (Bold, Italic, Underline) +- Font Color and Text Alignment +- Fill Color (background) and Stroke Color (border) +- Border Thickness and Opacity + +See the sections below for screenshots and details. + +#### Edit the properties of free text annotations + +Font family, font size, styles, font color, text alignment, fill color, stroke color, border thickness, and opacity can be edited using the Font Family, Font Size, Font Color, Text Align, Font Style, Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit font family + +Edit the font family by selecting a font in the Font Family tool. + +![Change font family](../../images/fontfamily.png) + +#### Edit font size + +Edit the font size by selecting a size in the Font Size tool. + +![Change font size](../../images/fontsize.png) + +#### Edit font color + +Edit the font color using the color palette in the Font Color tool. + +![Change font color](../../images/fontcolor.png) + +#### Edit text alignment + +Align text by selecting an option from the Text Align tool. + +![Set text alignment](../../images/textalign.png) + +#### Edit text styles + +Edit text styles by selecting options in the Font Style tool. + +![Change text styles](../../images/fontstyle.png) + +#### Edit fill color + +Edit the fill color using the color palette in the Edit Color tool. + +![Change fill color](../../images/fillcolor.png) + +#### Edit stroke color + +Edit the stroke color using the color palette in the Edit Stroke Color tool. + +![Change stroke color](../../images/fontstroke.png) + +#### Edit thickness + +Edit border thickness using the range slider in the Edit Thickness tool. + +![Change border thickness](../../images/fontthickness.png) + +#### Edit opacity + +Edit opacity using the range slider in the Edit Opacity tool. + +![Change opacity](../../images/fontopacity.png) + +### Edit Free Text annotation programmatically + +Use editAnnotation to update existing Free Text content. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function changeContent() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Text Box') { + ann.dynamicText = 'syncfusion'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function changeContent() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Text Box') { + ann.dynamicText = 'syncfusion'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + + + + + +## Default Free Text settings during initialization + +Set default Free Text properties before creating the control using freeTextSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `FreeTextSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default FreeText settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addFreeTextWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('FreeText', { + offset: { x: 120, y: 80 }, + pageNumber: 1, + width: 200, + height: 40, + fontSize: 16, + fontFamily: 'Helvetica', + isLock: false, + defaultText: 'Syncfusion', + fillColor: 'green', + borderColor: 'blue', + fontColor: 'yellow' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addFreeTextWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('FreeText', { + offset: { x: 120, y: 80 }, + pageNumber: 1, + width: 200, + height: 40, + fontSize: 16, + fontFamily: 'Helvetica', + isLock: false, + defaultText: 'Syncfusion', + fillColor: 'green', + borderColor: 'blue', + fontColor: 'yellow' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/highlight-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/highlight-annotation.md new file mode 100644 index 000000000..000a5bad6 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/highlight-annotation.md @@ -0,0 +1,623 @@ +--- +layout: post +title: Highlight annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and customize Highlight text markup annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Highlight annotation in React PDF Viewer + +The PDF Viewer provides options to add, edit, and delete Highlight annotations on text. You can add highlights via the UI (context menu or annotation toolbar) and programmatically. You can also customize color, opacity, author/subject, and default settings, and use undo/redo, save, print, or disable highlights as needed. + +![Alt text](../../images/highlight_context.png) + +## Add Highlight Annotation + +### Add highlight annotation via UI + +You can add highlights in two ways: + +1. Using the context menu +- Select text in the PDF document and right-click it. +- Choose **Highlight** in the context menu. + +![Alt text](../annotation-images/highlight-context.gif) + +2. Using the annotation toolbar +- Click the **Edit Annotation** button in the PDF Viewer toolbar to open the annotation toolbar. +- Select **Highlight** to enable highlight mode. +- Select text to add the highlight annotation. Alternatively, select text first and then click **Highlight**. + +![Alt text](../annotation-images/highlight-tool.gif) + +N> When pan mode is active and a text markup mode is entered, the PDF Viewer switches to text selection mode to enable selection. + +### Enable Highlight Mode + +The PDF Viewer component allows add highlight annotations programmatically after enabling Highlight mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, Annotation, FormDesigner, FormFields, TextSearch, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function enableHighlightMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Highlight'); + } + + return ( +
+ {/* Element to set text markup annotation mode */} + + +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, add the below `serviceUrl` in the `index.ts` file: `pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/highlight-mode-cs1" %} + +#### Exit Highlight mode + +To switch back to normal mode from highlight mode: +{% tabs %} +{% highlight ts tabtitle="index.ts" %} + +// Common (Standalone/Server-Backed) +function exitHighlightMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// Add the buttons inside your component JSX: +// +// +// + +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, add the below `serviceUrl` in the `index.ts` file: +`pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/highlight-normal-mode-cs1" %} + +### Add highlight annotation programmatically + +Programmatically add highlights using the [addAnnotation](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#addannotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addHighlight() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Highlight', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addHighlight() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Highlight', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Highlight Annotation + +### Edit highlight annotation in UI + +You can select a highlight to change its appearance or remove it: +- Change appearance using the annotation toolbar: Edit Color and Edit Opacity. +- Delete using Delete/Backspace keys or the Delete Annotation button in the annotation toolbar. + +#### Edit color +Use the color palette in the Edit Color tool to change the annotation color. + +![Alt text](../../images/edit_color.png) + +#### Edit opacity +Use the range slider in the Edit Opacity tool to change annotation opacity. + +![Alt text](../../images/edit_opacity.png) + +#### Delete highlight annotation +- Select the annotation and press Delete, or +- Click **Delete Annotation** in the annotation toolbar. + +![Alt text](../../images/delete_button.png) + +### Edit highlight annotation programmatically + +Modify an existing highlight programmatically using `editAnnotation()`. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editHighlight() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const annot = viewer.annotationCollection[i]; + if (annot.textMarkupAnnotationType === 'Highlight') { + annot.color = '#000fff'; // ensure valid hex string, e.g., '#000fff' + annot.opacity = 0.8; + viewer.annotation.editAnnotation(annot); + break; + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editHighlight() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const annot = viewer.annotationCollection[i]; + if (annot.textMarkupAnnotationType === 'Highlight') { + annot.color = '#000fff'; + annot.opacity = 0.8; + viewer.annotation.editAnnotation(annot); + break; + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set default properties during control initialization + +Set default properties before creating the control using `highlightSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default highlight settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, Annotation, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ) +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, Annotation, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ) +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `highlightSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default highlight settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +i +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addIndividualHighlights() { + const viewer = document.getElementById('container').ej2_instances[0]; + + // First highlight + viewer.annotation.addAnnotation('Highlight', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + }); + + // Second highlight + viewer.annotation.addAnnotation('Highlight', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', // ensure this matches your version's color format (hex) + opacity: 0.9 + }); + } + + return ( +
+ +
+ + + +
+
+ ) +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addIndividualHighlights() { + const viewer = document.getElementById('container').ej2_instances[0]; + + viewer.annotation.addAnnotation('Highlight', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + }); + + viewer.annotation.addAnnotation('Highlight', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + }); + } + + return ( +
+ +
+ + + +
+
+ ) +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Disable highlight annotation + +Disable text markup annotations (including highlight) using the `enableTextMarkupAnnotation` property. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, Annotation, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ) +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, Annotation, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ) +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/ink-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/ink-annotation.md new file mode 100644 index 000000000..4fe52583e --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/ink-annotation.md @@ -0,0 +1,533 @@ +--- +layout: post +title: Ink (freehand) annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and set defaults for Ink (freehand) annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Ink (freehand) annotation in React PDF Viewer + +Ink is a freehand drawing annotation used to sketch, sign, or mark up content. + +![Ink annotations overview](../../images/ink_annotation.png) + +## Add Ink Annotation + +### Add ink annotation via UI + +Use the annotation toolbar: +- Click the Edit Annotation button in the PDF Viewer toolbar. +- Click the Draw Ink button to enable ink mode. +- Draw on any page of the PDF document. + +![Ink tool in the annotation toolbar](../../images/ink_tool.png) + +### Enable ink mode + +The PDF Viewer component allows add ink annotations programmatically after enabling ink mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function inkMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Ink'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit ink mode + +{% tabs %} +{% highlight ts tabtitle="Common" %} + +// Common (works for both Standalone and Server-Backed) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// In your JSX: +// + +{% endhighlight %} +{% endtabs %} + +### Add ink annotation programmatically + +Use addAnnotation to programmatically create an Ink annotation. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addInkProgram() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Ink', { + offset: { x: 150, y: 100 }, + pageNumber: 1, + width: 200, + height: 60, + path: '[{"command":"M","x":244.83,"y":982.00},{"command":"L","x":250.83,"y":953.33}]' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addInkProgram() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Ink', { + offset: { x: 150, y: 100 }, + pageNumber: 1, + width: 200, + height: 60, + path: '[{"command":"M","x":244.83,"y":982.00},{"command":"L","x":250.83,"y":953.33}]' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Ink Annotation + +### Edit ink annotation in UI + +You can select, move, and resize Ink annotations directly in the viewer: +- Select an Ink annotation to show its handles. +- Move: drag inside the stroke to reposition it on the page. +- Resize: drag the selector handles to adjust its bounds. +- Delete or access more options from the context menu. + +#### Edit the properties of ink annotations + +Stroke color, thickness, and opacity can be edited using the Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit stroke color + +Edit the stroke color using the color palette in the Edit Stroke Color tool. + +![Change ink stroke color](../../images/ink_strokecolor.png) + +#### Edit thickness + +Edit thickness using the range slider in the Edit Thickness tool. + +![Change ink thickness](../../images/ink_thickness.png) + +#### Edit opacity + +Edit opacity using the range slider in the Edit Opacity tool. + +![Change ink opacity](../../images/ink_opacity.png) + +### Edit an existing ink annotation programmatically + +Use editAnnotation to modify properties and bounds of an existing ink annotation. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editInkAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.shapeAnnotationType === 'Ink') { + const { width, height } = ann.bounds; + ann.bounds = { x: 100, y: 100, width, height }; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editInkAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.shapeAnnotationType === 'Ink') { + const { width, height } = ann.bounds; + ann.bounds = { x: 100, y: 100, width, height }; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + + + +## Default ink settings during initialization + +Set defaults using inkAnnotationSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `InkSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Ink settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addInkWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Ink', { + offset: { x: 150, y: 100 }, + pageNumber: 1, + width: 200, + height: 60, + path: '[{"command":"M","x":244.83,"y":982.00},{"command":"L","x":250.83,"y":953.33}]', + author: 'Syncfusion', + strokeColor: 'green', + thickness: 3, + opacity: 0.6 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addInkWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Ink', { + offset: { x: 150, y: 100 }, + pageNumber: 1, + width: 200, + height: 60, + path: '[{"command":"M","x":244.83,"y":982.00},{"command":"L","x":250.83,"y":953.33}]', + author: 'Syncfusion', + strokeColor: 'green', + thickness: 3, + opacity: 0.6 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/line-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/line-annotation.md new file mode 100644 index 000000000..c108957d2 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/line-annotation.md @@ -0,0 +1,585 @@ +--- +layout: post +title: Line annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Line annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Line annotation in React PDF Viewer + +Line is a shape annotation used to mark straight connections or callouts. Common use cases include underline-like rulers, connectors, and measurement guides. + +![Line annotations overview](../annotation-images/line-annot.png) + +## Add Line Annotation + +### Add line annotation via UI + +Use the annotation toolbar: +- Click the **Edit Annotation** button in the PDF Viewer toolbar. +- Open the **Shape Annotation** dropdown. +- Choose **Line**, then draw on the page. + +N> When in pan mode, selecting a shape annotation switches the viewer to text select mode. + +![Shape toolbar](../annotation-images/line-annot.png) + +### Enable line mode + +The PDF Viewer component allows to add line annotations programmatically after enabling line mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function lineMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Line'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function lineMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Line'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit line mode + +{% tabs %} +{% highlight ts tabtitle="Common" %} +// Common (works for both Standalone and Server-Backed) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// Add in your JSX: +// + +{% endhighlight %} +{% endtabs %} + +### Add a line annotation programmatically + +Use the addAnnotation method with Line settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addLineAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Line', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addLineAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Line', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Line Annotation + +### Edit Line Annotation in UI + +You can select, move, and resize Line annotations directly in the viewer: +- Select a Line to show its end-point handles. +- Move: drag the line to reposition it on the page. +- Resize/reshape: drag either end-point to adjust the line. +- Delete or access more options from the context menu. + +Use the toolbar to change appearance: +- Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools. + +![Shape tools](../../images/shape_toolbar.png) + +#### Editing the properties of the shape annotation + +The fill color, stroke color, thickness, and opacity of shape annotations can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Editing fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![Edit fill color for shapes](../../images/shape_fillColor.png) + +#### Editing stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![Edit stroke color for shapes](../../images/shape_strokecolor.png) + +#### Editing thickness + +The thickness of the border of the annotation can be edited using the range slider provided in the Edit Thickness tool. + +![Edit thickness for shapes](../../images/shape_thickness.png) + +#### Editing opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![Edit opacity for shapes](../../images/shape_opacity.png) + +#### Editing the line properties + +Line annotations have additional options in the Line Properties window. Open it by right-clicking a line or arrow annotation and selecting Properties from the context menu. + +![Line properties dialog](../../images/shape_lineprty.png) + +### Edit an existing line annotation programmatically + +To modify an existing line annotation programmatically, use the editAnnotation() method. + +Here is an example of using editAnnotation(): + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editLineAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Line') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editLineAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Line') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default line settings during initialization + +Set default properties before creating the control using lineSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +N> In both [Arrow](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#arrowsettings) and [Line](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#linesettings) annotations Settings, the Fill Color option is available only when an arrowhead style is applied at the Start or End. If both Start and End arrowhead styles are set to None, lines do not support fill rendering and the Fill Color option remains disabled. + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `lineSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default line settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addLineWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.lineSettings = { opacity: 0.5 }; // optional global default + + viewer.annotation.addAnnotation('Line', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }], + // To see fillColor, ensure arrowheads are applied (depending on version settings) + fillColor: '#ff1010ff', + strokeColor: '#fff000', + opacity: 0.9, + author: 'User 1', + thickness: 1 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addLineWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Line', { + offset: { x: 200, y: 230 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 230 }, { x: 350, y: 230 }], + fillColor: '#ff1010ff', + strokeColor: '#fff000', + opacity: 0.9, + author: 'User 1', + thickness: 1 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/perimeter-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/perimeter-annotation.md new file mode 100644 index 000000000..0f4e464ad --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/perimeter-annotation.md @@ -0,0 +1,657 @@ +--- +layout: post +title: Perimeter annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Perimeter measurement annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Perimeter annotation in React PDF Viewer + +Perimeter is a measurement annotation used to measure the length around a closed polyline in the PDF. + +![Measurement annotations overview](../annotation-images/perimeter-annot.png) + +## Add Perimeter Annotation + +### Add perimeter annotation via UI + +Use the annotation toolbar: +- Click the Edit Annotation button in the PDF Viewer toolbar. +- Click the Measurement Annotation dropdown. +- Choose Perimeter, then draw the polyline on the page. + +N> When in pan mode, selecting a measurement annotation switches the viewer to text select mode. + +![Measurement toolbar](../../images/calibrate_tool.png) + +### Enable perimeter mode + +The PDF Viewer library allows drawing measurement annotations programmatically after enabling perimeter mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function perimeterMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Perimeter'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function perimeterMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Perimeter'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +### Add a perimeter annotation programmatically + +The PDF Viewer library allows adding measurement annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPerimeterAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Perimeter', { + offset: { x: 200, y: 350 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 350 }, { x: 285, y: 350 }, { x: 286, y: 412 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPerimeterAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Perimeter', { + offset: { x: 200, y: 350 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 350 }, { x: 285, y: 350 }, { x: 286, y: 412 }] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Perimeter Annotation + +### Edit perimeter annotation in UI + +You can select, move, and resize Perimeter annotations directly in the viewer: +- Select a Perimeter to show its vertex handles. +- Move: drag inside the shape to reposition it on the page. +- Resize/reshape: drag any vertex handle to adjust the polyline points and size. +- Delete or access more options from the context menu. + +#### Edit the properties of Perimeter annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing perimeter annotation programmatically + +To modify an existing perimeter annotation programmatically, use the editAnnotation() method. + +Here is an example of using editAnnotation(): + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editPerimeterAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Perimeter calculation') { + ann.annotationSelectorSettings.resizerShape = 'Circle'; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editPerimeterAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Perimeter calculation') { + ann.annotationSelectorSettings.resizerShape = 'Circle'; + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default perimeter settings during initialization + +Set default perimeterSettings before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `PerimeterSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Perimeter settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPerimeterWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Perimeter', { + offset: { x: 200, y: 350 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 350 }, { x: 285, y: 350 }, { x: 286, y: 412 }], + fillColor: 'green', + opacity: 0.6, + strokeColor: 'blue' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPerimeterWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Perimeter', { + offset: { x: 200, y: 350 }, + pageNumber: 1, + vertexPoints: [{ x: 200, y: 350 }, { x: 285, y: 350 }, { x: 286, y: 412 }], + fillColor: 'green', + opacity: 0.6, + strokeColor: 'blue' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Editing scale ratio and unit of the perimeter measurement annotation + +The scale ratio and unit of measurement can be modified using the scale ratio option provided in the context menu of the PDF Viewer control. + +![Scale ratio](../../images/calibrate_scaleratio.png) + +The Units of measurements support for the measurement annotations in the PDF Viewer are + +- Inch +- Millimeter +- Centimeter +- Point +- Pica +- Feet + +![Scale dialog](../../images/calibrate_scaledialog.png) + +## Setting default scale ratio settings during control initialization + +The properties of scale ratio for measurement annotation can be set before creating the control using measurementSettings as shown in the following code snippet, + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/polygon-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/polygon-annotation.md new file mode 100644 index 000000000..d769adcea --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/polygon-annotation.md @@ -0,0 +1,588 @@ +--- +layout: post +title: Polygon annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Polygon annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Polygon annotation in React PDF Viewer + +Polygon is a shape annotation used to outline irregular regions, highlight areas, or create custom callouts. + +![Polygon annotations overview](../annotation-images/polygon-annot.png) + +## Add Polygon Annotation + +### Add polygon annotation via UI + +Use the annotation toolbar: +- Click the Edit Annotation button in the PDF Viewer toolbar. +- Open the Shape Annotation dropdown. +- Choose Polygon, then draw on the page. + +N> When in pan mode, selecting a shape annotation switches the viewer to text select mode. + +![Shape toolbar](../../images/shape_toolbar.png) + +### Enable polygon mode + +The PDF Viewer library allows drawing shape annotations programmatically after enabling polygon mode in button clicks. + + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function polygonMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Polygon'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function polygonMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Polygon'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit polygon mode + + +{% tabs %} +{% highlight ts tabtitle="Common" %} + +// Common (works for both Standalone and Server-Backed) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// In your JSX: +// + +{% endhighlight %} +{% endtabs %} + +### Add a polygon annotation programmatically + +The PDF Viewer library allows adding polygon annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPolygonAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Polygon', { + offset: { x: 200, y: 800 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 800 }, { x: 242, y: 771 }, { x: 289, y: 799 }, + { x: 278, y: 842 }, { x: 211, y: 842 }, { x: 200, y: 800 } + ] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPolygonAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Polygon', { + offset: { x: 200, y: 800 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 800 }, { x: 242, y: 771 }, { x: 289, y: 799 }, + { x: 278, y: 842 }, { x: 211, y: 842 }, { x: 200, y: 800 } + ] + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Polygon Annotation + +### Edit Polygon Annotation in UI + +You can select, move, and resize Polygon annotations directly in the viewer: +- Select a Polygon to show its vertex handles. +- Move: drag inside the shape to reposition it on the page. +- Resize/reshape: drag any vertex handle to adjust the polygon points and size. +- Delete or access more options from the context menu. + +Use the toolbar to change appearance: +- Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools. + +See the sections below for details. + +#### Edit the properties of area annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing polygon annotation programmatically + +Use editAnnotation on items from annotationCollection. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editPolygonAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Polygon') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editPolygonAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Polygon') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); + +{% endhighlight %} +{% endtabs %} + +## Default polygon settings during initialization + +Set default properties before creating the control using polygonSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `PolygonSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Polygon settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPolygonWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Polygon', { + offset: { x: 200, y: 800 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 800 }, { x: 242, y: 771 }, { x: 289, y: 799 }, + { x: 278, y: 842 }, { x: 211, y: 842 }, { x: 200, y: 800 } + ], + fillColor: '#ff0000', // valid hex + opacity: 0.9, + strokeColor: '#ff0000' // valid hex + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addPolygonWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Polygon', { + offset: { x: 200, y: 800 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 800 }, { x: 242, y: 771 }, { x: 289, y: 799 }, + { x: 278, y: 842 }, { x: 211, y: 842 }, { x: 200, y: 800 } + ], + fillColor: '#ff0000', + opacity: 0.9, + strokeColor: '#ff0000' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/radius-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/radius-annotation.md new file mode 100644 index 000000000..89697cbfe --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/radius-annotation.md @@ -0,0 +1,654 @@ +--- +layout: post +title: Radius annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Radius measurement annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Radius annotation in React PDF Viewer + +Radius is a measurement annotation used to measure the radius of a circle in the PDF. + +![Radius annotations overview](../annotation-images/radius-annot.png) + +## Add Radius Annotation + +### Add radius annotation via UI + +Use the annotation toolbar: +- Click the Edit Annotation button in the PDF Viewer toolbar. +- Open the Measurement Annotation dropdown. +- Choose Radius, then draw on the page. + +N> When in pan mode, selecting a measurement annotation switches the viewer to text select mode. + +![Measurement toolbar](../../images/calibrate_tool.png) + +### Enable radius mode + +The PDF Viewer component allows drawing Radius annotations programmatically after enabling Radius mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function radiusMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Radius'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function radiusMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Radius'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit radius mode + +{% tabs %} +{% highlight ts tabtitle="Common" %} + +// Common (works for both Standalone and Server-Backed) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// Add in your JSX: +// +{% endhighlight %} +{% endtabs %} + +### Add a radius annotation programmatically + +Add measurement annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRadiusAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Radius', { + offset: { x: 200, y: 630 }, + pageNumber: 1, + width: 90, + height: 90 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRadiusAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Radius', { + offset: { x: 200, y: 630 }, + pageNumber: 1, + width: 90, + height: 90 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Radius Annotation + +### Edit radius annotation in UI + +You can select, move, and resize Radius annotations directly in the viewer: +- Select a Radius measurement to show its handles. +- Move: drag the shape to reposition it on the page. +- Resize: drag the handles to adjust its size. +- Delete or access more options from the context menu. + +#### Edit the properties of radius annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing radius annotation programmatically + +Use editAnnotation on items from annotationCollection. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editRadiusAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Radius calculation') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.opacity = 0.8; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editRadiusAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Radius calculation') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.opacity = 0.8; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default radius settings during initialization + +Set default [radiusSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#radiussettings) before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `RadiusSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Radius settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRadiusWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Radius', { + offset: { x: 200, y: 630 }, + pageNumber: 1, + width: 90, + height: 90, + fillColor: 'orange', + opacity: 0.6, + strokeColor: 'pink' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRadiusWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Radius', { + offset: { x: 200, y: 630 }, + pageNumber: 1, + width: 90, + height: 90, + fillColor: 'orange', + opacity: 0.6, + strokeColor: 'pink' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Scale ratio and units + +You can modify scale ratio and units using the Scale Ratio option in the context menu. + +![Scale ratio](../../images/calibrate_scaleratio.png) + +Supported units: +- Inch, Millimeter, Centimeter, Point, Pica, Feet + +![Scale dialog](../../images/calibrate_scaledialog.png) + +Set defaults via measurementSettings: + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/rectangle-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/rectangle-annotation.md new file mode 100644 index 000000000..91800b742 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/rectangle-annotation.md @@ -0,0 +1,579 @@ +--- +layout: post +title: Rectangle annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Rectangle annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Rectangle annotation in React PDF Viewer + +Rectangle is a shape annotation used to highlight regions, group content, or draw callout boxes. + +![Rectangle annotations overview](../annotation-images/rect-annot.png) + +## Add Rectangle Annotation + +### Add rectangle annotation via UI + +Use the annotation toolbar: +- Click the Edit Annotation button in the PDF Viewer toolbar. +- Open the Shape Annotation dropdown. +- Choose Rectangle, then draw on the page. + +N> When pan mode is active and a shape tool is selected, the viewer switches to text select mode automatically. + +![Shape toolbar](../../images/shape_toolbar.png) + +### Enable rectangle mode + +The PDF Viewer library allows drawing shape annotations programmatically after enabling rectangle mode in button clicks. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function rectangleMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Rectangle'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function rectangleMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('Rectangle'); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +#### Exit rectangle mode + + +{% tabs %} +{% highlight ts tabtitle="Common" %} + +// Common (works for both Standalone and Server-Backed) +function exitMode() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.setAnnotationMode('None'); +} + +// In your JSX: +// + +{% endhighlight %} +{% endtabs %} + +### Add a rectangle annotation programmatically + +Use the addAnnotation method with Rectangle settings to add a rectangle annotation programmatically. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRectangleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Rectangle', { + offset: { x: 200, y: 480 }, + pageNumber: 1, + width: 150, + height: 75 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRectangleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Rectangle', { + offset: { x: 200, y: 480 }, + pageNumber: 1, + width: 150, + height: 75 + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Edit Rectangle Annotation + +### Edit Rectangle Annotation in UI + +You can select, move, and resize Rectangle annotations directly in the viewer: +- Select a Rectangle to show its resize handles. +- Move: drag inside the shape to reposition it on the page. +- Resize: drag any corner or side handle to adjust size. +- Delete or access more options from the context menu. + +Use the toolbar to change appearance: +- Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools. + +#### Edit the properties of area annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing rectangle annotation programmatically + +Use editAnnotation on items from annotationCollection. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editRectangleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Rectangle') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function editRectangleAnnotation() { + const viewer = document.getElementById('container').ej2_instances[0]; + for (let i = 0; i < viewer.annotationCollection.length; i++) { + const ann = viewer.annotationCollection[i]; + if (ann.subject === 'Rectangle') { + ann.strokeColor = '#0000FF'; + ann.thickness = 2; + ann.fillColor = '#FFFF00'; + ann.annotationSelectorSettings.resizerShape = 'Circle'; + viewer.annotation.editAnnotation(ann); + } + } + } + + return ( +
+ +
+ + + +
+
+ ); +} + +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Default rectangle settings during initialization + +Set default properties before creating the control using rectangleSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + return ( +
+
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `RectangleSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default rectangle settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRectangleWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Rectangle', { + offset: { x: 200, y: 480 }, + pageNumber: 1, + width: 150, + height: 75, + opacity: 0.5, + strokeColor: '#FF0000', + fillColor: '#000fff', // valid hex (no trailing '#') + author: 'User1' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import * as ReactDOM from 'react-dom/client'; +import * as React from 'react'; +import './index.css'; +import { + PdfViewerComponent, + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, + Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, Inject +} from '@syncfusion/ej2-react-pdfviewer'; + +export function App() { + function addRectangleWithSettings() { + const viewer = document.getElementById('container').ej2_instances[0]; + viewer.annotation.addAnnotation('Rectangle', { + offset: { x: 200, y: 480 }, + pageNumber: 1, + width: 150, + height: 75, + opacity: 0.5, + strokeColor: '#FF0000', + fillColor: '#000fff', // valid hex + author: 'User1' + }); + } + + return ( +
+ +
+ + + +
+
+ ); +} +const root = ReactDOM.createRoot(document.getElementById('sample')); +root.render(); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/redaction-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/redaction-annotation.md new file mode 100644 index 000000000..260b06b00 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/redaction-annotation.md @@ -0,0 +1,210 @@ +--- +layout: post +title: Overview of Redaction in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and apply redaction annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Redaction annotation in React PDF Viewer + +Redaction annotations permanently remove sensitive content from a PDF. You can draw redaction marks over text or graphics, redact entire pages, customize overlay text and styling, and apply redaction to finalize. + +![Toolbar with the Redaction tool highlighted](../../Redaction/redaction-annotations-images/redaction-icon-toolbar.png) + +## Add Redaction Annotation + +### Add redaction annotation in UI + +- Use the Redaction tool from the toolbar to draw over content to hide. +- Redaction marks can show overlay text (for example, "Confidential") and can be styled. + +![Drawing a redaction annotation on the page](../../Redaction/redaction-annotations-images/adding-redaction-annotation.png) + +Redaction annotations are interactive: +- Movable +![Moving a redaction annotation](../../Redaction/redaction-annotations-images/moving-redaction-annotation.png) +- Resizable +![Resizing a redaction annotation](../../Redaction/redaction-annotations-images/resizing-redaction-annotation.png) + +You can also add redaction from the context menu by selecting content and choosing Redact Annotation. + +![Context menu showing Redact Annotation option](../../Redaction/redaction-annotations-images/redact-text-context-menu.png) + +N> Ensure the Redaction tool is included in the toolbar. See [RedactionToolbar](../../Redaction/toolbar.md) for configuration. + +### Add a redaction annotation programmatically + +Use the addAnnotation method with the Redaction type. + +```html + +``` +```ts +document.getElementById('addRedactAnnot')?.addEventListener('click', () => { + viewer.annotation.addAnnotation('Redaction', { + bound: { x: 200, y: 480, width: 150, height: 75 }, + pageNumber: 1, + markerFillColor: '#0000FF', + markerBorderColor: 'white', + fillColor: 'red', + overlayText: 'Confidential', + fontColor: 'yellow', + fontFamily: 'Times New Roman', + fontSize: 8, + beforeRedactionsApplied: false + }); +}); +``` + +Track additions using the annotationAdd event. + +```ts +viewer.annotationAdd = (args) => { + console.log('Annotation added:', args); +}; +``` + +## Edit Redaction Annotation + +### Edit redaction annotation in UI + +You can select, move, and resize Redaction annotations directly in the viewer. Use the context menu for additional actions. + +#### Edit the properties of redaction annotations in UI + +Use the property panel or context menu Properties to change overlay text, font, fill color, and more. + +![Redaction Property Panel Icon](../../Redaction/redaction-annotations-images/redaction-property-panel-icon.png) +![Redaction Property Panel via Context Menu](../../Redaction/redaction-annotations-images/redaction-property-panel-via-context-menu.png) + +### Edit a redaction annotation programmatically + +Use editAnnotation to modify overlay text, colors, fonts, etc. + +```html + +``` +```ts +document.getElementById('editRedactAnnotation')?.addEventListener('click', () => { + for (let i = 0; i < viewer.annotationCollection.length; i++) { + if (viewer.annotationCollection[i].subject === 'Redaction') { + viewer.annotationCollection[i].overlayText = 'EditedAnnotation'; + viewer.annotationCollection[i].markerFillColor = '#22FF00'; + viewer.annotationCollection[i].markerBorderColor = '#000000'; + viewer.annotationCollection[i].isRepeat = true; + viewer.annotationCollection[i].fillColor = '#F8F8F8'; + viewer.annotationCollection[i].fontColor = '#333333'; + viewer.annotationCollection[i].fontSize = 14; + viewer.annotationCollection[i].fontFamily = 'Symbol'; + viewer.annotationCollection[i].textAlign = 'Right'; + viewer.annotationCollection[i].beforeRedactionsApplied = false; + viewer.annotation.editAnnotation(viewer.annotationCollection[i]); + } + } +}); +``` + +## Delete redaction annotations + +### Delete in UI + +- Right-click and select Delete +![Context menu showing Delete for a redaction](../../Redaction/redaction-annotations-images/redaction-delete-context-menu.png) +- Use the Delete button in the toolbar +![Toolbar delete icon for redaction](../../Redaction/redaction-annotations-images/redaction-delete-icon.png) +- Press Delete key + +### Delete programmatically + +Delete by id using deleteAnnotationById: + +```html + +``` +```ts +document.getElementById('deleteAnnotationbyId')?.addEventListener('click', () => { + viewer.annotationModule.deleteAnnotationById(viewer.annotationCollection[0].annotationId); +}); +``` + +## Redact pages + +### Redact pages in UI + +Use the Redact Pages dialog to mark entire pages: + +![Page Redaction Panel](../../Redaction/redaction-annotations-images/page-redaction-panel.png) + +Options include Current Page, Odd Pages Only, Even Pages Only, and Specific Pages. + +### Add page redactions programmatically + +```html + +``` +```ts +document.getElementById('addPageRedactions')?.addEventListener('click', () => { + viewer.annotation.addPageRedactions([1, 3, 5, 7]); +}); +``` + +## Apply redaction + +### Apply redaction in UI + +Click Apply Redaction to permanently remove marked content. + +![Redact Button Icon](../../Redaction/redaction-annotations-images/redact-button-icon.png) +![Apply Redaction Dialog](../../Redaction/redaction-annotations-images/apply-redaction-dialog.png) + +N> Redaction is permanent and cannot be undone. + +### Apply redaction programmatically + +```html + +``` +```ts +document.getElementById('redact')?.addEventListener('click', () => { + viewer.annotation.redact(); +}); +``` + +N> Applying redaction is irreversible. + +## Default redaction settings during initialization + +Configure defaults with redactionSettings: + +```ts +viewer.redactionSettings = { + overlayText: 'Confidential', + markerFillColor: '#FF0000', + markerBorderColor: '#000000', + isRepeat: false, + fillColor: '#F8F8F8', + fontColor: '#333333', + fontSize: 14, + fontFamily: 'Symbol', + textAlign: 'Right' +}; +``` + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Redaction Overview](../../Redaction/overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/squiggly-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/squiggly-annotation.md new file mode 100644 index 000000000..c66c06a0b --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/squiggly-annotation.md @@ -0,0 +1,352 @@ +--- +layout: post +title: Squiggly annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and customize Squiggly text markup annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Squiggly annotation in React PDF Viewer + +The PDF Viewer provides options to add, edit, and delete Squiggly text markup annotations on text. You can add squiggles via the UI (context menu or annotation toolbar) and programmatically. You can also customize color, opacity, author/subject, and default settings, and use undo/redo, save, print, or disable them as needed. + +![Squiggly annotations overview](../../images/squiggly_button.png) + +## Add Squiggly Annotation + +### Add squiggly annotation in UI + +You can add squiggly annotations in two ways: + +1. Using the context menu +* Select text in the PDF document and right-click it. +* Choose **Squiggly** in the context menu. + +![Squiggly context](../annotation-images/squiggle-context.gif) + +2. Using the annotation toolbar +* Click the **Edit Annotation** button in the PDF Viewer toolbar to open the annotation toolbar. +* Select **Squiggly** to enable squiggly mode. +* Select text to add the squiggly annotation. +* Alternatively, select text first and then click **Squiggly**. + +![Squiggly toolbar](../annotation-images/squiggle-tool.gif) + +N> When in pan mode, selecting a text markup annotation switches the PDF Viewer to text select mode. + +### Enable Squiggly Mode + +Enable/exit squiggly mode using the following code: + +```html + + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('squigglyMode')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('Squiggly'); +}); + +document.getElementById('setNone')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('None'); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('squigglyMode')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('Squiggly'); +}); + +document.getElementById('setNone')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('None'); +}); +{% endhighlight %} +{% endtabs %} + +### Add squiggly annotation programmatically + +Add squiggly annotations programmatically using the [addAnnotation](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#addannotation) method. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, SquigglySettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('addSquiggly')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Squiggly', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + } as SquigglySettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, SquigglySettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('addSquiggly')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Squiggly', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + } as SquigglySettings); +}); +{% endhighlight %} +{% endtabs %} + +## Edit Squiggly Annotation + +### Edit Squiggly annotation in UI + +The color and opacity of the squiggly annotation can be edited using the Edit Color and Edit Opacity tools in the annotation toolbar. + +#### Edit color +Use the color palette in the Edit Color tool to change the annotation color. + +![Edit color](../../images/edit_color.png) + +#### Edit opacity +Use the range slider in the Edit Opacity tool to change annotation opacity. + +![Edit opacity](../../images/edit_opacity.png) + +#### Delete Squiggly annotation + +- Select the annotation and press Delete, or +- Click **Delete Annotation** in the annotation toolbar. + +![Delete button](../../images/delete_button.png) + +### Edit a squiggly annotation programmatically + +To modify an existing squiggly annotation programmatically, use the editAnnotation() method. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editSquiggly')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + const ann = pdfviewer.annotationCollection[i]; + if (ann.author === 'Guest User' || ann.subject === 'Corrections') { + ann.color = '#ff0000'; + ann.opacity = 0.8; + pdfviewer.annotation.editAnnotation(ann); + } + } +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editSquiggly')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + const ann = pdfviewer.annotationCollection[i]; + if (ann.author === 'Guest User' || ann.subject === 'Corrections') { + ann.color = '#ff0000'; + ann.opacity = 0.8; + pdfviewer.annotation.editAnnotation(ann); + } + } +}); +{% endhighlight %} +{% endtabs %} + +## Set default properties during control initialization + +Set default properties before creating the control using `squigglySettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + squigglySettings: { author: 'Guest User', subject: 'Corrections', color: '#00ff00', opacity: 0.9} +}); +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + squigglySettings: { author: 'Guest User', subject: 'Corrections', color: '#00ff00', opacity: 0.9} +}); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `SquigglySettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default highlight settings. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, SquigglySettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +//Apply Squiggly Settings while adding individual Annotation +document.getElementById('squiggly')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Squiggly', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + } as SquigglySettings); + + pdfviewer.annotation.addAnnotation('Squiggly', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + } as SquigglySettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, SquigglySettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); + +//Apply Squiggly Settings while adding individual Annotation +document.getElementById('squiggly')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Squiggly', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + } as SquigglySettings); + + pdfviewer.annotation.addAnnotation('Squiggly', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + } as SquigglySettings); +}); +{% endhighlight %} +{% endtabs %} + +## Disable squiggly annotation + +Disable text markup annotations (including squiggly) using the `enableTextMarkupAnnotation` property. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath= 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.enableTextMarkupAnnotation= false; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath='https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.enableTextMarkupAnnotation= false; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/stamp-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/stamp-annotation.md new file mode 100644 index 000000000..59e11ecdc --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/stamp-annotation.md @@ -0,0 +1,353 @@ +--- +layout: post +title: Stamp annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, rotate, and customize Stamp annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Stamp annotation in React PDF Viewer + +The PDF Viewer control provides options to add, edit, delete, and rotate the following stamp annotations in PDF documents: + +* Dynamic +* Sign Here +* Standard Business +* Custom Stamp + +![Stamp annotations overview](../../images/stamp_annot.png) + +## Add Stamp Annotation + +### Add Stamp Annotation in UI + +Use the annotation toolbar: +- Click the Edit Annotation button. +- Open the Stamp Annotation dropdown. +![Stamp tool](../../images/stamp_tool.png) +- Choose a stamp type and place it on the page. +![Select stamp type](../../images/selectstamp_annot.png) + +N> When in pan mode and a stamp tool is selected, the viewer switches to text select mode automatically. + +### Switch to specific stamp modes + +```html + + + + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, SignStampItem, StandardBusinessStampItem, DynamicStampItem, StampSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('dynamicStamp')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Stamp', DynamicStampItem.NotApproved); +}); + +document.getElementById('signStamp')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Stamp', undefined, SignStampItem.Witness); +}); + +document.getElementById('standardBusinessStamp')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Stamp', undefined, undefined, StandardBusinessStampItem.Approved); +}); + +document.getElementById('customStamp')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 100, y: 440 }, + width: 46, + height: 100, + pageNumber: 1, + isLock: true, + author: 'Guest', + customStamps: [{ + customStampName: 'Image', + customStampImageSource: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...' + }] + } as unknown as StampSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, SignStampItem, StandardBusinessStampItem, DynamicStampItem, StampSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('dynamicStamp')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Stamp', DynamicStampItem.NotApproved); +}); + +document.getElementById('signStamp')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Stamp', undefined, SignStampItem.Witness); +}); + +document.getElementById('standardBusinessStamp')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Stamp', undefined, undefined, StandardBusinessStampItem.Approved); +}); +{% endhighlight %} +{% endtabs %} + +### Add Stamp Annotation programmatically + +Create stamps via addAnnotation. + +```html + + + + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, StampSettings, DynamicStampItem, SignStampItem, StandardBusinessStampItem } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('addDynamic')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 140 }, pageNumber: 1 + } as StampSettings, DynamicStampItem.Approved); +}); + +document.getElementById('addSign')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 240 }, pageNumber: 1 + } as StampSettings, undefined, SignStampItem.Witness); +}); + +document.getElementById('addStandard')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 340 }, pageNumber: 1 + } as StampSettings, undefined, undefined, StandardBusinessStampItem.Approved); +}); + +document.getElementById('addCustom')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 100, y: 440 }, width: 46, height: 100, pageNumber: 1, isLock: true, + author: 'Guest', + customStamps: [{ customStampName: 'Image', customStampImageSource: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...' }] + } as unknown as StampSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, StampSettings, DynamicStampItem, SignStampItem, StandardBusinessStampItem } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('addDynamic')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 140 }, pageNumber: 1 + } as StampSettings, DynamicStampItem.Approved); +}); + +document.getElementById('addSign')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 240 }, pageNumber: 1 + } as StampSettings, undefined, SignStampItem.Witness); +}); + +document.getElementById('addStandard')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 340 }, pageNumber: 1 + } as StampSettings, undefined, undefined, StandardBusinessStampItem.Approved); +}); + +document.getElementById('addCustom')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 100, y: 440 }, width: 46, height: 100, pageNumber: 1, isLock: true, + author: 'Guest', + customStamps: [{ customStampName: 'Image', customStampImageSource: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD...' }] + } as StampSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Edit Stamp Annotation + +### Edit Stamp Annotation in UI + +You can select, move, resize, rotate, and delete Stamp annotations directly in the viewer: +- Select a Stamp to show its resize and rotation handles. +- Move: drag inside the stamp to reposition it on the page. +- Resize: drag any corner or side handle to adjust the size. +- Rotate: drag the rotation handle to rotate the stamp. +- Delete or access more options from the context menu. + +Use the toolbar to change appearance: +- Adjust Opacity using the Edit Opacity tool. + +### Edit Stamp Annotation programmatically + +Use editAnnotation to change bounds or lock state. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; + +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editStamp')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].shapeAnnotationType === 'stamp') { + const width = pdfviewer.annotationCollection[i].bounds.width; + const height = pdfviewer.annotationCollection[i].bounds.height; + pdfviewer.annotationCollection[i].bounds = { x: 100, y: 100, width, height }; + pdfviewer.annotationCollection[i].annotationSettings.isLock = true; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + } + } +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editStamp')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].shapeAnnotationType === 'stamp') { + const width = pdfviewer.annotationCollection[i].bounds.width; + const height = pdfviewer.annotationCollection[i].bounds.height; + pdfviewer.annotationCollection[i].bounds = { x: 100, y: 100, width, height }; + pdfviewer.annotationCollection[i].annotationSettings.isLock = true; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + } + } +}); +{% endhighlight %} +{% endtabs %} + +## Default stamp settings during initialization + +Set defaults using stampSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.stampSettings = { opacity: 0.3, author: 'Guest User' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.stampSettings = { opacity: 0.3, author: 'Guest User' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `StampSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Stamp settings. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, DynamicStampItem, StampSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); +//Apply Stamp Settings while adding individual Annotation +document.getElementById('Stamp')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 140 }, pageNumber: 1, + opacity: 0.3, author: 'Guest User' + } as StampSettings, DynamicStampItem.Approved); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, DynamicStampItem, StampSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); +//Apply Stamp Settings while adding individual Annotation +document.getElementById('Stamp')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Stamp', { + offset: { x: 200, y: 140 }, pageNumber: 1, + opacity: 0.3, author: 'Guest User' + } as StampSettings, DynamicStampItem.Approved); +}); +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/sticky-notes-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/sticky-notes-annotation.md new file mode 100644 index 000000000..866849618 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/sticky-notes-annotation.md @@ -0,0 +1,287 @@ +--- +layout: post +title: Sticky notes annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and customize Sticky Notes annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Sticky notes annotation in React PDF Viewer + +Sticky Notes are comment annotations used to leave notes, replies, and review statuses anywhere on a page. + +![Sticky notes overview](../../images/stickynotes_annotation.png) + +## Add Annotation + +### Add Annotation in UI + +Use the Comments tool: +- Click the Comments button in the PDF Viewer toolbar. +- Click on the page where the sticky note should be added. +- The sticky note icon is placed at the clicked position. + +![Sticky notes tool](../../images/stickynotes_tool.png) + +Add and manage comments using the comment panel: +- Select a sticky note, right‑click, and choose Comment. +- Add comments, replies, and statuses in the panel. + +![Sticky notes comment panel](../../images/stickynotes_comment.png) + +### Add Annotation programmatically + +Use addAnnotation to programmatically create a sticky note. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, StickyNotesSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('stickyNote')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('StickyNotes', { + offset: { x: 100, y: 200 }, + pageNumber: 1, + isLock: false + } as StickyNotesSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, StickyNotesSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('stickyNote')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('StickyNotes', { + offset: { x: 100, y: 200 }, + pageNumber: 1, + isLock: false + } as StickyNotesSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Edit Annotation + +### Edit Annotation in UI + +You can select and manage sticky notes directly in the viewer: +- Select: click the sticky note icon to focus it and show context actions. +- Move: drag the icon to reposition on the page. +- Delete or more options: use the context menu on the selected note. +- Open comments: right-click the note and choose Comment, or use the Comment Panel button. + +#### Edit the properties of sticky note annotations + +#### Editing opacity + +Edit opacity using the range slider in the Edit Opacity tool. + +![StickyNotesOpacity](../../images/sticky_opacity.png) + +#### Editing comments + +Comment text, replies, and status can be edited using the comment panel. + +* Open the comment panel using the Comment Panel button in the annotation toolbar. + + ![StickyNotesComment](../../images/commentPanel.png) + +Modify or delete comments or replies, and change status using the menu options in the comment panel. + + ![StickyNotesEdit](../../images/sticky_editbtn.png) + +### Edit Annotation programmatically + +Use editAnnotation to update an existing note's bounds. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editSticky')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].shapeAnnotationType === 'sticky') { + const width = pdfviewer.annotationCollection[i].bounds.width; + const height = pdfviewer.annotationCollection[i].bounds.height; + pdfviewer.annotationCollection[i].bounds = { x: 100, y: 100, width, height }; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + } + } +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editSticky')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].shapeAnnotationType === 'sticky') { + const width = pdfviewer.annotationCollection[i].bounds.width; + const height = pdfviewer.annotationCollection[i].bounds.height; + pdfviewer.annotationCollection[i].bounds = { x: 100, y: 100, width, height }; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + } + } +}); +{% endhighlight %} +{% endtabs %} + +## Default Sticky Notes settings during initialization + +Set defaults using stickyNotesSettings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.stickyNotesSettings = { author: 'Syncfusion' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.stickyNotesSettings = { author: 'Syncfusion' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `StickyNotesSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default StickyNotes settings. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, StickyNotesSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); +//Apply StickyNotes Settings while adding individual Annotation +document.getElementById('StickyNotes')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('StickyNotes', { + offset: { x: 100, y: 200 }, + pageNumber: 1, + isLock: false, + author: 'Syncfusion' + } as StickyNotesSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, StickyNotesSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); +//Apply StickyNotes Settings while adding individual Annotation +document.getElementById('StickyNotes')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('StickyNotes', { + offset: { x: 100, y: 200 }, + pageNumber: 1, + isLock: false, + author: 'Syncfusion' + } as StickyNotesSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Disable Sticky Notes + +Disable the feature by setting enableStickyNotesAnnotation to false. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.enableStickyNotesAnnotation = false; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.enableStickyNotesAnnotation = false; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/strikethrough-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/strikethrough-annotation.md new file mode 100644 index 000000000..34e224460 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/strikethrough-annotation.md @@ -0,0 +1,464 @@ +--- +layout: post +title: Strikethrough annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and customize Strikethrough text markup annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Strikethrough annotation in React PDF Viewer + +The PDF Viewer provides options to add, edit, and delete Strikethrough annotations on text. You can add strikethrough via the UI (context menu or annotation toolbar) and programmatically. You can also customize color, opacity, author/subject, and default settings, and use undo/redo, save, print, or disable them as needed. + +![Strikethrough overview](../../images/strikethrough_button.png) + +## Add strikethrough annotation + +### Add strikethrough annotation via UI + +You can add strikethrough in two ways: + +1. Using the context menu +* Select text in the PDF document and right-click it. +* Choose **Strikethrough** in the context menu. + +![Strikethrough context](../annotation-images/strikethrough-context.gif) + + +2. Using the annotation toolbar +* Click the **Edit Annotation** button in the PDF Viewer toolbar to open the annotation toolbar. +* Select **Strikethrough** to enable strikethrough mode. +* Select text to add the strikethrough annotation. +* Alternatively, select text first and then click **Strikethrough**. + +![Strikethrough toolbar](../annotation-images/strikethrough-tool.gif) + +When pan mode is active and a text markup mode is entered, the PDF Viewer switches to text selection mode to enable selection. + +### Enable strikethrough mode + +Use the following code to switch the viewer into strikethrough mode. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, + BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib' +}); +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('set')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('Strikethrough'); +}); +{% endhighlight %} +{% highlight html tabtitle="index.html" %} + + + + EJ2 PDF Viewer + + + + + + + + + + +
Loading....
+ + +
+
+
+ + + +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, +Add the below `serviceUrl` in the `index.ts` file +`pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/strikethrough-mode-cs1" %} + +#### Exit strikethrough mode + +Use the following code to switch back to normal mode. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, + BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib' +}); +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('set')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('Strikethrough'); +}); + +document.getElementById('setNone')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('None'); +}); +{% endhighlight %} +{% highlight html tabtitle="index.html" %} + + + + EJ2 PDF Viewer + + + + + + + + + + +
Loading....
+ + + + +
+
+
+ + + +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, +Add the below `serviceUrl` in the `index.ts` file +`pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/strikethrough-normal-mode-cs1" %} + +### Add strikethrough annotation programmatically + +Programmatically add strikethrough using the [addAnnotation](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#addannotation) method. + +Example: + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, StrikethroughSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +let strikethrough = document.getElementById('strikethrough'); +if (strikethrough) { + strikethrough.addEventListener('click', function () { + if (pdfviewer) { + pdfviewer.annotation.addAnnotation('Strikethrough', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + } as StrikethroughSettings); + } + }); +} + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, StrikethroughSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.appendTo('#PdfViewer'); + +let strikethrough = document.getElementById('strikethrough'); +if (strikethrough) { + strikethrough.addEventListener('click', function () { + if (pdfviewer) { + pdfviewer.annotation.addAnnotation('Strikethrough', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + } as StrikethroughSettings); + } + }); +} + +{% endhighlight %} +{% endtabs %} + +## Edit strikethrough annotation + +### Edit strikethrough annotation in UI + +The color and opacity of the strikethrough annotation can be edited using the Edit Color and Edit Opacity tools in the annotation toolbar. + +#### Edit color +Use the color palette in the Edit Color tool to change the annotation color. + +![Edit color](../../images/edit_color.png) + +#### Edit opacity +Use the range slider in the Edit Opacity tool to change annotation opacity. + +![Edit opacity](../../images/edit_opacity.png) + +#### Delete strikethrough annotation + +- Select the annotation and press Delete, or +- Click **Delete Annotation** in the annotation toolbar. + +![Delete button](../../images/delete_button.png) + +### Edit an existing strikethrough annotation programmatically + +To modify an existing strikethrough annotation programmatically, use the editAnnotation() method. Example: + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +let editStrikethroughAnnotation = document.getElementById('editStrikethroughAnnotation'); +if (editStrikethroughAnnotation) { + editStrikethroughAnnotation.addEventListener('click', function () { + if (pdfviewer) { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + // Update the first available Strikethrough annotation + if (pdfviewer.annotationCollection[i].textMarkupAnnotationType === 'Strikethrough') { + pdfviewer.annotationCollection[i].color = '#ff0000'; + pdfviewer.annotationCollection[i].opacity = 0.8; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + break; + } + } + } + }); +} + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +let editStrikethroughAnnotation = document.getElementById('editStrikethroughAnnotation'); +if (editStrikethroughAnnotation) { + editStrikethroughAnnotation.addEventListener('click', function () { + if (pdfviewer) { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].textMarkupAnnotationType === 'Strikethrough') { + pdfviewer.annotationCollection[i].color = '#ff0000'; + pdfviewer.annotationCollection[i].opacity = 0.8; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + break; + } + } + } + }); +} + +{% endhighlight %} +{% endtabs %} + +## Default strikethrough settings during initialization + +Set default properties before creating the control using `strikethroughSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default strikethrough settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + strikethroughSettings: { author: 'Guest User', subject: 'Not Important', color: '#ff00ff', opacity: 0.9} +}); +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + strikethroughSettings: { author: 'Guest User', subject: 'Not Important', color: '#ff00ff', opacity: 0.9} +}); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `StrikethroughSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default highlight settings. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, StrikethroughSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +//Apply Strikethrough Settings while adding individual Annotation +document.getElementById('Strikethrough')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Strikethrough', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + } as StrikethroughSettings); + + pdfviewer.annotation.addAnnotation('Strikethrough', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + } as StrikethroughSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, StrikethroughSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); + +//Apply Strikethrough Settings while adding individual Annotation +document.getElementById('Strikethrough')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Strikethrough', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + } as StrikethroughSettings); + + pdfviewer.annotation.addAnnotation('Strikethrough', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + } as StrikethroughSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Disable strikethrough annotation + +Disable text markup annotations (including strikethrough) using the `enableTextMarkupAnnotation` property. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.enableTextMarkupAnnotation= false; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.enableTextMarkupAnnotation= false; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/underline-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/underline-annotation.md new file mode 100644 index 000000000..860e77af5 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/underline-annotation.md @@ -0,0 +1,463 @@ +--- +layout: post +title: Underline annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, delete, and customize Underline text markup annotations in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Underline annotation in React PDF Viewer + +The PDF Viewer provides options to add, edit, and delete Underline annotations on text. You can add underlines via the UI (context menu or annotation toolbar) and programmatically. You can also customize color, opacity, author/subject, and default settings, and use undo/redo, save, print, or disable them as needed. + +![Underline overview](../../images/underline_button.png) + +## Add underline annotation + +### Add underline annotation via UI + +You can add underlines in two ways: + +1. Using the context menu +* Select text in the PDF document and right-click it. +* Choose **Underline** in the context menu. + +![Underline context](../annotation-images/underline-context.gif) + + +2. Using the annotation toolbar +* Click the **Edit Annotation** button in the PDF Viewer toolbar to open the annotation toolbar. +* Select **Underline** to enable underline mode. +* Select text to add the underline annotation. +* Alternatively, select text first and then click **Underline**. + +![Underline toolbar](../annotation-images/underline-tool.gif) + +When pan mode is active and a text markup mode is entered, the PDF Viewer switches to text selection mode to enable selection. + +### Enable underline mode + +Use the following code to switch the viewer into underline mode. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, + BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib' +}); +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('set')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('Underline'); +}); +{% endhighlight %} +{% highlight html tabtitle="index.html" %} + + + + EJ2 PDF Viewer + + + + + + + + + + +
Loading....
+ + +
+
+
+ + + +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, +Add the below `serviceUrl` in the `index.ts` file +`pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/underline-mode-cs1" %} + +#### Exit underline mode + +Use the following code to switch back to normal mode. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, + BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib' +}); +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('set')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('Underline'); +}); + +document.getElementById('setNone')?.addEventListener('click', () => { + pdfviewer.annotation.setAnnotationMode('None'); +}); +{% endhighlight %} +{% highlight html tabtitle="index.html" %} + + + + EJ2 PDF Viewer + + + + + + + + + + +
Loading....
+ + + + +
+
+
+ + + +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, +Add the below `serviceUrl` in the `index.ts` file +`pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/underline-normal-mode-cs1" %} + +### Add underline annotation programmatically + +Programmatically add underlines using the [addAnnotation](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#addannotation) method. + +Example: + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, UnderlineSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +let underline = document.getElementById('underline'); +if (underline) { + underline.addEventListener('click', function () { + if (pdfviewer) { + pdfviewer.annotation.addAnnotation('Underline', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + } as UnderlineSettings); + } + }); +} + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, UnderlineSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.appendTo('#PdfViewer'); + +let underline = document.getElementById('underline'); +if (underline) { + underline.addEventListener('click', function () { + if (pdfviewer) { + pdfviewer.annotation.addAnnotation('Underline', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1 + } as UnderlineSettings); + } + }); +} + +{% endhighlight %} +{% endtabs %} + +## Edit underline annotation + +### Edit underline annotation in UI + +The color and opacity of the underline annotation can be edited using the Edit Color and Edit Opacity tools in the annotation toolbar. + +#### Edit color +Use the color palette in the Edit Color tool to change the annotation color. + +![Edit color](../../images/edit_color.png) + +#### Edit opacity +Use the range slider in the Edit Opacity tool to change annotation opacity. + +![Edit opacity](../../images/edit_opacity.png) + +#### Delete underline annotation + +- Select the annotation and press Delete, or +- Click **Delete Annotation** in the annotation toolbar. + +![Delete button](../../images/delete_button.png) + +### Edit an existing underline annotation programmatically + +To modify an existing underline annotation programmatically, use the editAnnotation() method. Example: + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +let editUnderlineAnnotation = document.getElementById('editUnderlineAnnotation'); +if (editUnderlineAnnotation) { + editUnderlineAnnotation.addEventListener('click', function () { + if (pdfviewer) { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + // Update the first available Underline annotation + if (pdfviewer.annotationCollection[i].textMarkupAnnotationType === 'Underline') { + pdfviewer.annotationCollection[i].color = '#00aa00'; + pdfviewer.annotationCollection[i].opacity = 0.8; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + break; + } + } + } + }); +} + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +let editUnderlineAnnotation = document.getElementById('editUnderlineAnnotation'); +if (editUnderlineAnnotation) { + editUnderlineAnnotation.addEventListener('click', function () { + if (pdfviewer) { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].textMarkupAnnotationType === 'Underline') { + pdfviewer.annotationCollection[i].color = '#00aa00'; + pdfviewer.annotationCollection[i].opacity = 0.8; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + break; + } + } + } + }); +} + +{% endhighlight %} +{% endtabs %} + +## Default underline settings during initialization + +Set default properties before creating the control using `underlineSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default underline settings. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.underlineSettings= { author: 'Guest User', subject: 'Points to be remembered', color: '#00ffff', opacity: 0.9}; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath= 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.underlineSettings= { author: 'Guest User', subject: 'Points to be remembered', color: '#00ffff', opacity: 0.9}; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `underlineSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default highlight settings. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, UnderlineSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +//Apply Underline Settings while adding individual Annotation +document.getElementById('underline')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Underline', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + } as UnderlineSettings); + + pdfviewer.annotation.addAnnotation('Underline', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + } as UnderlineSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, UnderlineSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); + +//Apply Underline Settings while adding individual Annotation +document.getElementById('underline')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Underline', { + bounds: [{ x: 97, y: 110, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 1', + color: '#ffff00', + opacity: 0.9 + } as UnderlineSettings); + + pdfviewer.annotation.addAnnotation('Underline', { + bounds: [{ x: 107, y: 220, width: 350, height: 14 }], + pageNumber: 1, + author: 'User 2', + color: '#ff1010ff', + opacity: 0.9 + } as UnderlineSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Disable underline annotation + +Disable text markup annotations (including underline) using the `enableTextMarkupAnnotation` property. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.enableTextMarkupAnnotation: false; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} + +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.enableTextMarkupAnnotation: false; +pdfviewer.appendTo('#PdfViewer'); + +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/volume-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/volume-annotation.md new file mode 100644 index 000000000..4cf956671 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/volume-annotation.md @@ -0,0 +1,361 @@ +--- +layout: post +title: Volume annotation in React PDF Viewer | Syncfusion +description: Learn to add, edit, and customize Volume measurement annotations in Syncfusion React PDF Viewer with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Volume annotation in React PDF Viewer + +Volume is a measurement annotation used to calculate the volume of a rectangular prism area in the PDF. + +![Volume annotations overview](../annotation-images/volume-annot.png) + +## Add Volume Annotation + +### Add volume annotation via UI + +Use the annotation toolbar: +- Click the Edit Annotation button in the PDF Viewer toolbar. +- Open the Measurement Annotation dropdown. +- Choose Volume, then draw on the page. + +N> When in pan mode, selecting a measurement annotation switches the viewer to text select mode. + +![Measurement toolbar](../../images/calibrate_tool.png) + +### Enable volume mode + +The PDF Viewer component allows drawing Volume annotations programmatically after enabling Volume mode in button clicks. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('volumeMode')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Volume'); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('volumeMode')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('Volume'); +}); +{% endhighlight %} +{% endtabs %} + +#### Exit volume mode + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Common" %} +document.getElementById('setNone')?.addEventListener('click', () => { + pdfviewer.annotationModule.setAnnotationMode('None'); +}); +{% endhighlight %} +{% endtabs %} + +### Add a volume annotation programmatically + +Add measurement annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, VolumeSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('addVolumeAnnotation')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Volume', { + offset: { x: 200, y: 810 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 810 }, { x: 200, y: 919 }, { x: 320, y: 919 }, { x: 320, y: 809 }, { x: 200, y: 810 } + ] + } as VolumeSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, VolumeSettings } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('addVolumeAnnotation')?.addEventListener('click', () => { + pdfviewer.annotation.addAnnotation('Volume', { + offset: { x: 200, y: 810 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 810 }, { x: 200, y: 919 }, { x: 320, y: 919 }, { x: 320, y: 809 }, { x: 200, y: 810 } + ] + } as VolumeSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Edit Volume Annotation + +### Edit volume annotation in UI + +You can select, move, and resize Volume annotations directly in the viewer: +- Select a Volume measurement to show its handles. +- Move: drag the shape to reposition it on the page. +- Resize: drag the handles to adjust its size. +- Delete or access more options from the context menu. + +#### Edit the properties of volume annotations + +The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar. + +#### Edit fill color + +The fill color of the annotation can be edited using the color palette provided in the Edit Color tool. + +![CalibrateFillColor](../../images/calibrate_fillcolor.png) + +#### Edit stroke color + +The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool. + +![CalibrateStrokeColor](../../images/calibrate_stroke.png) + +#### Edit thickness + +Edit border thickness using the range slider provided in the Edit Thickness tool. + +![CalibrateThickness](../../images/calibrate_thickness.png) + +#### Edit opacity + +The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool. + +![CalibrateOpacity](../../images/calibrate_opacity.png) + +### Edit an existing volume annotation programmatically + +Use editAnnotation on items from annotationCollection. + +```html + +``` + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editVolumeAnnotation')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].subject === 'Volume calculation') { + pdfviewer.annotationCollection[i].strokeColor = '#0000FF'; + pdfviewer.annotationCollection[i].thickness = 2; + pdfviewer.annotationCollection[i].opacity = 0.8; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + } + } +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('editVolumeAnnotation')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + if (pdfviewer.annotationCollection[i].subject === 'Volume calculation') { + pdfviewer.annotationCollection[i].strokeColor = '#0000FF'; + pdfviewer.annotationCollection[i].thickness = 2; + pdfviewer.annotationCollection[i].opacity = 0.8; + pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]); + } + } +}); +{% endhighlight %} +{% endtabs %} + +## Default volume settings during initialization + +Set default [volumeSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#volumesettings) before creating the control. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.volumeSettings = { fillColor: 'pink', opacity: 0.6, strokeColor: 'yellow' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.volumeSettings = { fillColor: 'pink', opacity: 0.6, strokeColor: 'yellow' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## Set properties while adding Individual Annotation + +Set properties for individual annotation before creating the control using `VolumeSettings`. + +> After editing default color and opacity using the Edit Color and Edit Opacity tools, the values update to the selected settings. + +Refer to the following code snippet to set the default Volume settings. + +```html + +``` +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, VolumeSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); +//Apply Volume Settings while adding individual Annotation +document.getElementById('Volume')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Volume', { + offset: { x: 200, y: 810 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 810 }, { x: 200, y: 919 }, { x: 320, y: 919 }, { x: 320, y: 809 }, { x: 200, y: 810 } + ], + fillColor: 'pink', opacity: 0.6, strokeColor: 'yellow' + } as VolumeSettings); +}); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, VolumeSettings} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/form-designer.pdf'; +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); +//Apply Volume Settings while adding individual Annotation +document.getElementById('Volume')?.addEventListener('click', function () { + pdfviewer.annotation.addAnnotation('Volume', { + offset: { x: 200, y: 810 }, + pageNumber: 1, + vertexPoints: [ + { x: 200, y: 810 }, { x: 200, y: 919 }, { x: 320, y: 919 }, { x: 320, y: 809 }, { x: 200, y: 810 } + ], + fillColor: 'pink', opacity: 0.6, strokeColor: 'yellow' + } as VolumeSettings); +}); +{% endhighlight %} +{% endtabs %} + +## Scale ratio and units + +You can modify scale ratio and units using the Scale Ratio option in the context menu. + +![Scale ratio](../../images/calibrate_scaleratio.png) + +Supported units: +- Inch, Millimeter, Centimeter, Point, Pica, Feet + +![Scale dialog](../../images/calibrate_scaledialog.png) + +Set defaults via measurementSettings: + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; +pdfviewer.measurementSettings = { scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer); + +let pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; +pdfviewer.measurementSettings = { scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm' }; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotations-api.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotations-api.md new file mode 100644 index 000000000..57e3a2d4f --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotations-api.md @@ -0,0 +1,1344 @@ +--- +layout: post +title: Annotations API in React PDF Viewer | Syncfusion +description: Learn how to read and configure annotations using APIs in the Syncfusion React PDF Viewer. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Annotations API in React PDF Viewer + +The PDF Viewer provides APIs to read the loaded annotations and to configure global defaults for creating/editing annotations. + +| API | Description | +|---|---| +| [annotationCollection](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationcollection) | Gets the loaded document annotation collection. | +| [annotationDrawingOptions](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationdrawingoptions) | Options to configure line-type annotation drawing behavior. | +| [annotationSelectorSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationselectorsettings) | Configures the annotation selector (selection UI). | +| [annotationSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationsettings) | Global defaults for all annotations. | +| [areaSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#areasettings) | Defaults for Area annotations. | +| [arrowSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#arrowsettings) | Defaults for Arrow annotations. | +| [circleSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#circlesettings) | Defaults for Circle annotations. | +| [customStamp](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#customstamp) | Defines custom stamp items. | +| [customStampSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#customstampsettings) | Defaults for Custom Stamp annotations. | +| [distanceSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#distancesettings) | Defaults for Distance annotations. | + +## annotationCollection + +Gets the loaded document annotation collection from the viewer instance. + +```html + +
+``` +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.appendTo('#PdfViewer'); + +const btn = document.getElementById('logAnnot'); +if (btn) { + btn.addEventListener('click', () => { + console.log(pdfviewer.annotationCollection); + }); +} +{% endhighlight %} +{% endtabs %} + +## annotationDrawingOptions + +Options for configuring line-type annotation drawing behavior. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.annotationDrawingOptions.enableLineAngleConstraints = true; +pdfviewer.annotationDrawingOptions.restrictLineAngleTo = 90; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## annotationSelectorSettings + +Defines the settings of the annotation selector. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.annotationSelectorSettings = { + selectionBorderColor: 'blue', + resizerBorderColor: 'red', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## annotationSettings + +Defines the global settings of annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.annotationSettings = { + author: 'XYZ', + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + skipPrint: false, + skipDownload: false, + allowedInteractions: [AllowedInteraction.Resize] +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## areaSettings + +Defines the defaults for Area annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.areaSettings = { + opacity: 1, + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'white', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## arrowSettings + +Defines the defaults for Arrow annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.arrowSettings = { + opacity: 1, + fillColor: '#9c2592', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + borderDashArray: 1, + lineHeadStartStyle: 'Closed', + lineHeadEndStyle: 'Closed', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 0, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## circleSettings + +Defines the defaults for Circle annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.circleSettings = { + opacity: 1, + fillColor: '#9c2592', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## customStamp + +Defines custom stamp items of the PDF Viewer. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.customStamp = [ + { + customStampName: 'Sample', + customStampImageSource: 'data:image/png;base64, Syncfusionpdfviewer' + } +]; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## customStampSettings + +Defines the defaults for Custom Stamp annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.customStampSettings = { + opacity: 1, + author: 'XYZ', + width: 100, + height: 100, + left: 200, + top: 200, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + enableCustomStamp: true, + allowedInteractions: [AllowedInteraction.None], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## distanceSettings + +Defines the defaults for Distance annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +pdfviewer.distanceSettings = { + opacity: 1, + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'Guest', + thickness: 1, + borderDashArray: 1, + lineHeadStartStyle: 'Closed', + lineHeadEndStyle: 'Closed', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + leaderLength: 40, + resizeCursorType: CursorType.move, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableAnnotation + +Enable or disable the Add/Edit Annotations tool in the toolbar. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableAnnotation = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableAnnotationToolbar + +Show or hide the annotation toolbar when the document loads. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableAnnotationToolbar = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableFreeText + +Enable or disable Free Text annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableFreeText = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableHandwrittenSignature + +Enable or disable the handwritten signature feature. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableHandwrittenSignature = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableInkAnnotation + +Enable or disable Ink annotations (true by default). + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableInkAnnotation = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableMeasureAnnotation + +Enable or disable calibrate/measurement annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableMeasureAnnotation = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableMultiPageAnnotation + +Enable or disable multi-page text markup selection in UI. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; + +pdfviewer.enableMultiPageAnnotation = true; + +pdfviewer.appendTo('#PdfViewer'); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/FormDesigner.pdf'; +{% endhighlight %} +{% endtabs %} + +## enableShapeAnnotation + +Enable or disable shape annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableShapeAnnotation = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableShapeLabel + +Enable or disable labels for shape annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableShapeLabel = true; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableStampAnnotations + +Enable or disable stamp annotations at load time. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableStampAnnotations = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableStickyNotesAnnotation + +Enable or disable sticky notes annotations at load time. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableStickyNotesAnnotation = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableTextMarkupAnnotation + +Enable or disable text markup annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableTextMarkupAnnotation = false; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## enableTextMarkupResizer + +Enable or disable the text markup resizer to modify bounds in the UI. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; + +pdfviewer.enableTextMarkupResizer = true; + +pdfviewer.appendTo('#PdfViewer'); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/FormDesigner.pdf'; +{% endhighlight %} +{% endtabs %} + +## exportAnnotationFileName + +Gets or sets the exported annotations JSON file name. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.exportAnnotationFileName = 'Annotation export file_1'; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## freeTextSettings + +Defines the defaults for Free Text annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, FontStyle, AnnotationResizerLocation, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.freeTextSettings = { + opacity: 1, + fillColor: '#ffffff00', + borderColor: '#4070ff', + author: 'XYZ', + borderWidth: 1, + width: 151, + fontSize: 16, + height: 24.6, + fontColor: '#000', + fontFamily: 'Helvetica', + defaultText: 'Type Here', + textAlignment: 'Right', + fontStyle: FontStyle.Italic, + allowTextOnly: false, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: null + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + allowedInteractions: [AllowedInteraction.None], + isPrint: true, + isReadonly: false, + enableAutoFit: false +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## handWrittenSignatureSettings + +Defines the defaults for handwritten signatures. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, DisplayMode, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.handWrittenSignatureSettings = { + signatureItem: ['Signature', 'Initial'], + saveSignatureLimit: 1, + saveInitialLimit: 1, + opacity: 1, + strokeColor: '#000000', + width: 150, + height: 100, + thickness: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + allowedInteractions: [AllowedInteraction.Resize], + signatureDialogSettings: { + displayMode: DisplayMode.Draw | DisplayMode.Text | DisplayMode.Upload, + hideSaveSignature: false + }, + initialDialogSettings: { + displayMode: DisplayMode.Draw | DisplayMode.Text | DisplayMode.Upload, + hideSaveSignature: false + } +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## highlightSettings + +Defines the defaults for Highlight annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.highlightSettings = { + opacity: 1, + color: '#DAFF56', + author: 'XYZ', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges + }, + isLock: false, + enableMultiPageAnnotation: false, + enableTextMarkupResizer: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## inkAnnotationSettings + +Defines the defaults for Ink annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.inkAnnotationSettings = { + author: 'XYZ', + opacity: 1, + strokeColor: '#ff0000', + thickness: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## isAnnotationToolbarVisible + +Open the annotation toolbar initially and read its visibility state. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; + +pdfviewer.isAnnotationToolbarVisible = true; + +pdfviewer.appendTo('#PdfViewer'); +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/FormDesigner.pdf'; +{% endhighlight %} +{% endtabs %} + +## lineSettings + +Defines the defaults for Line annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.lineSettings = { + opacity: 1, + color: '#9c2592', + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + borderDashArray: 1, + lineHeadStartStyle: 'None', + lineHeadEndStyle: 'None', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: null + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## measurementSettings + +Defines the defaults for Measurement annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.measurementSettings = { + conversionUnit: 'cm', + displayUnit: 'cm', + scaleRatio: 1, + depth: 96 +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## perimeterSettings + +Defines the defaults for Perimeter annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.perimeterSettings = { + opacity: 1, + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + borderDashArray: 1, + lineHeadStartStyle: 'Open', + lineHeadEndStyle: 'Open', + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## polygonSettings + +Defines the defaults for Polygon annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.polygonSettings = { + opacity: 1, + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## radiusSettings + +Defines the defaults for Radius annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.radiusSettings = { + opacity: 1, + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'red', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## rectangleSettings + +Defines the defaults for Rectangle annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.rectangleSettings = { + opacity: 1, + fillColor: '#9c2592', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## shapeLabelSettings + +Defines the defaults for shape labels. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.enableShapeLabel = true; +pdfviewer.shapeLabelSettings = { + opacity: 1, + fillColor: '#9c2592', + borderColor: '#ff0000', + fontColor: '#000', + fontSize: 16, + labelHeight: 24.6, + labelMaxWidth: 151, + labelContent: 'XYZ' +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## stampSettings + +Defines the defaults for Stamp annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, DynamicStampItem, SignStampItem, StandardBusinessStampItem, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.stampSettings = { + opacity: 1, + author: 'XYZ', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'red', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 5, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + dynamicStamps: [ + DynamicStampItem.Revised, + DynamicStampItem.Reviewed, + DynamicStampItem.Received, + DynamicStampItem.Confidential, + DynamicStampItem.Approved, + DynamicStampItem.NotApproved + ], + signStamps: [ + SignStampItem.Witness, + SignStampItem.InitialHere, + SignStampItem.SignHere, + SignStampItem.Accepted, + SignStampItem.Rejected + ], + standardBusinessStamps: [ + StandardBusinessStampItem.Approved, + StandardBusinessStampItem.NotApproved, + StandardBusinessStampItem.Draft, + StandardBusinessStampItem.Final, + StandardBusinessStampItem.Completed, + StandardBusinessStampItem.Confidential, + StandardBusinessStampItem.ForPublicRelease, + StandardBusinessStampItem.NotForPublicRelease, + StandardBusinessStampItem.ForComment, + StandardBusinessStampItem.Void, + StandardBusinessStampItem.PreliminaryResults, + StandardBusinessStampItem.InformationOnly + ], + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## stickyNotesSettings + +Defines the defaults for Sticky Notes annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.stickyNotesSettings = { + author: 'XYZ', + opacity: 1, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'red', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + isLock: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## strikethroughSettings + +Defines the defaults for Strikethrough annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.strikethroughSettings = { + opacity: 1, + color: '#DAFF56', + author: 'XYZ', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges + }, + isLock: false, + enableMultiPageAnnotation: false, + enableTextMarkupResizer: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## underlineSettings + +Defines the defaults for Underline annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.underlineSettings = { + opacity: 1, + color: '#9c2592', + author: 'XYZ', + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#FF4081', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Square', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges + }, + isLock: false, + enableMultiPageAnnotation: false, + enableTextMarkupResizer: false, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## volumeSettings + +Defines the defaults for Volume annotations. + +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, AnnotationResizerLocation, CursorType, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner); + +const pdfviewer: PdfViewer = new PdfViewer(); +pdfviewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +pdfviewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/PDF_Succinctly.pdf'; + +pdfviewer.volumeSettings = { + opacity: 1, + fillColor: '#ffffff00', + strokeColor: '#ff0000', + author: 'XYZ', + thickness: 1, + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + annotationSelectorSettings: { + selectionBorderColor: 'blue', + resizerBorderColor: 'black', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }, + allowedInteractions: [AllowedInteraction.Resize], + isPrint: true +}; + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/annotations-undo-redo.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotations-undo-redo.md new file mode 100644 index 000000000..638f2af42 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/annotations-undo-redo.md @@ -0,0 +1,74 @@ +--- +layout: post +title: Undo and Redo annotation in React PDF Viewer | Syncfusion +description: Learn to undo and redo annotations changes in Syncfusion React PDF Viewer, with UI and programmatic examples. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Perform undo and redo in React + +The PDF Viewer supports undo and redo for Annotations. + +![Undo-redo](../annotations/annotation-images/annotation-undo-redo.png) + +Undo and redo actions can be performed in the following ways: + +1. Using keyboard shortcuts: + After performing a highlight annotation action, press Ctrl+Z to undo and Ctrl+Y to redo. +2. Using the toolbar: + Use the **Undo** and **Redo** tools in the toolbar. + +Refer to the following code snippet to call undo and redo actions from the client side. + +```html + + + + +``` +{% tabs %} +{% highlight ts tabtitle="index.ts" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation,ThumbnailView, BookmarkView, + TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject( Toolbar,Magnification, Navigation, LinkAnnotation,ThumbnailView, + BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath:'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl:"https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib" +}); +pdfviewer.appendTo('#PdfViewer'); + +document.getElementById('undo').addEventListener('click', ()=> { + pdfviewer.undo(); +}); + +document.getElementById('redo').addEventListener('click', ()=> { + pdfviewer.redo(); +}); +{% endhighlight %} +{% endtabs %} + +N> To set up the **server-backed PDF Viewer**, +Add the below `serviceUrl` in the `index.ts` file +`pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';` + +{% previewsample "/document-processing/code-snippet/pdfviewer/javascript-es6/text-markup-annotation/undo-redo-cs1" %} + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export and Import Annotation](../../annotations/export-import/export-annotation) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotations API](../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/create-modify-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/create-modify-annotation.md new file mode 100644 index 000000000..4aa5ea7db --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/create-modify-annotation.md @@ -0,0 +1,150 @@ +--- +layout: post +title: Create and modify annotations in React PDF Viewer | Syncfusion +description: Learn how to create and modify annotations in Syncfusion React PDF Viewer with UI and programmatic examples, plus quick links to all annotation types. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Create and modify annotations in React PDF Viewer + +Use the PDF Viewer annotation tools to add, edit, and manage markups across your documents. This page provides a quick overview with convenient navigation to each annotation type and common ways to create and modify annotations. + +## Quick navigation to annotation types + +Jump directly to a specific annotation type for detailed usage and examples: + +TextMarkup Annotations: + +- Highlight : [Highlight annotation](./annotation-types/highlight-annotation) +- Strikethrough: [Strikethrough annotation](./annotation-types/strikethrough-annotation) +- Underline: [Underline annotation](./annotation-types/underline-annotation) +- Squiggly: [Squiggly annotation](./annotation-types/Squiggly-annotation) + +Shape Annotations: + +- Line: [Line annotation](./annotation-types/line-annotation) +- Arrow: [Arrow annotation](./annotation-types/arrow-annotation) +- Rectangle: [Rectangle annotation](./annotation-types/rectangle-annotation) +- Circle : [Circle annotation](./annotation-types/circle-annotation) +- Polygon: [Polygon annotation](./annotation-types/polygon-annotation) + +Measurement Annotations: + +- Distance: [Distance annotation](./annotation-types/distance-annotation) +- Perimeter: [Perimeter annotation](./annotation-types/perimeter-annotation) +- Area: [Area annotation](./annotation-types/area-annotation) +- Radius: [Radius annotation](./annotation-types/ra) +- Volume: [Volume annotation](./annotation-types/vo) + +Other Annotations: + +- Redaction: [Redaction annotation](./annotation-types/redaction-annotation) +- Free Text: [Free text annotation](./annotation-types/free-text-annotation) +- Ink (Freehand): [Ink annotation](./annotation-types/ink-annotation) +- Stamp: [Stamp annotation](./annotation-types/stamp-annotation) +- Sticky Notes: [Sticky notes annotation](./annotation-types/sticky-notes-annotation) + +N> Each annotation type page includes both UI steps and programmatic examples specific to that type. + +## Create annotations + +### Create via UI + +- Open the annotation toolbar in the PDF Viewer. +- Choose the required tool (for example, Shape, Free Text, Ink, Stamp, Redaction). +- Click or drag on the page to place the annotation. + +![Annotation toolbar](../images/shape_toolbar.png) + +Notes: +- When pan mode is active and you select a shape or stamp tool, the viewer switches to text select mode automatically. +- Property pickers in the annotation toolbar let you choose color, stroke color, thickness, and opacity while drawing. + +### Create programmatically + +Creation patterns vary slightly by type. Refer to the type pages above for tailored code. Example: creating a Redaction annotation using addAnnotation. + +```html + +``` +```ts +// Requires a PdfViewer instance named `viewer` +document.getElementById('addRedactAnnot')?.addEventListener('click', () => { + viewer.annotation.addAnnotation('Redaction', { + bound: { x: 200, y: 480, width: 150, height: 75 }, + pageNumber: 1, + markerFillColor: '#0000FF', + markerBorderColor: 'white', + fillColor: 'red', + overlayText: 'Confidential', + fontColor: 'yellow', + fontFamily: 'Times New Roman', + fontSize: 8, + beforeRedactionsApplied: false + }); +}); +``` + +See the individual annotation pages (links above) for enabling draw modes from UI buttons and other type-specific creation samples. + +## Modify annotations + +### Modify via UI + +Use the annotation toolbar after selecting an annotation: +- Edit Color: change the fill or text color (when applicable) +![Edit color](../images/edit_color.png) +- Edit Stroke Color: change the border/line color (shape and line types) +![Edit stroke color](../images/shape_strokecolor.png) +- Edit Thickness: adjust the border/line thickness +![Edit thickness](../images/shape_thickness.png) +- Edit Opacity: change transparency +![Edit opacity](../images/shape_opacity.png) + + +Additional options such as Line Properties (for line/arrow) are available from the context menu (right-click > Properties) where supported. + +### Modify programmatically + +Use editAnnotation to apply changes to an existing annotation. Common flow: +- Locate the target annotation from annotationCollection +- Update the desired properties +- Call editAnnotation with the modified object + +```html + +``` +```ts +// Example: change color/opacity for matching annotations +// Requires a PdfViewer instance named `pdfviewer` +document.getElementById('bulkEdit')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + const ann = pdfviewer.annotationCollection[i]; + // Example match: author/subject; customize the condition as needed + if (ann.author === 'Guest User' || ann.subject === 'Corrections') { + ann.color = '#ff0000'; + ann.opacity = 0.8; + pdfviewer.annotation.editAnnotation(ann); + } + } +}); +``` + +N> For type-specific edit examples (for example, editing line endings, moving stamps, or updating sticky note bounds), see the corresponding annotation type page linked above. + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Customize Annotation](../annotations/customize-annotation) +- [Remove Annotation](../annotations/delete-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation Permission](../annotations/annotation-permission) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation API](../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/custom-data.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/custom-data.md new file mode 100644 index 000000000..3050be4e5 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/custom-data.md @@ -0,0 +1,143 @@ +--- +layout: post +title: Custom Data in annotations in React PDF Viewer | Syncfusion +description: Learn how to use add custom Data in annotation in Syncfusion React PDF Viewer +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Custom data in annotations in React PDF Viewer + +You can attach any custom key–value data to annotations using the customData property. This works at two levels: +- Default level with annotationSettings: Applies to all annotations created via the UI. +- Per-annotation-type level: Supply customData in each annotation type settings (highlightSettings, rectangleSettings, etc.). + +The customData value can be any serializable object. It is preserved when exporting or importing annotations and is available at runtime on the annotation object. + +## Default custom data (annotationSettings) + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, TextSearch, Print, Annotation, FormFields, FormDesigner, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject( + Toolbar, + Magnification, + Navigation, + LinkAnnotation, + ThumbnailView, + BookmarkView, + TextSelection, + TextSearch, + Print, + Annotation, + FormFields, + FormDesigner +); + +const viewer: PdfViewer = new PdfViewer(); +viewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +viewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; + +// Default annotation settings applied to annotations created via the UI +viewer.annotationSettings = { + author: 'XYZ', + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + allowedInteractions: [AllowedInteraction.Resize], + // Custom data applied to all newly created annotations + customData: { + appId: 'pdf-review', + tenant: 'northwind', + featureFlags: { allowShare: true, qaStamp: false } + } +}; + +viewer.appendTo('#pdfViewer'); +``` + +## Custom data for Individual Annotation + +Provide customData inside individual annotation-type settings when you want specific payloads for different tools. + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +const pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib', + + // Text markup + highlightSettings: { author: 'QA', subject: 'Review', color: '#ffff00', opacity: 0.6, customData: { tag: 'needs-review', priority: 'high' } }, + strikethroughSettings: { author: 'QA', subject: 'Remove', color: '#ff0000', opacity: 0.6, customData: { tag: 'remove', priority: 'medium' } }, + underlineSettings: { author: 'Guest User', subject: 'Notes', color: '#00ffff', opacity: 0.9, customData: { tag: 'note', owner: 'guest' } }, + squigglySettings: { author: 'Guest User', subject: 'Corrections', color: '#00ff00', opacity: 0.9, customData: { tag: 'typo' } }, + + // Shapes + lineSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, customData: { id: 'ln-1', category: 'connector' } }, + arrowSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, customData: { id: 'ar-1', category: 'direction' } }, + rectangleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1, customData: { id: 'rect-1', zone: 'content' } }, + circleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1, customData: { id: 'circ-1', zone: 'highlight' } }, + polygonSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1, customData: { id: 'poly-1', group: 'area' } }, + + // Measurements + distanceSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, customData: { units: 'cm', scale: 1 } }, + perimeterSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, customData: { units: 'cm', calc: 'perimeter' } }, + areaSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00', customData: { units: 'cm^2', calc: 'area' } }, + radiusSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00', customData: { units: 'cm', calc: 'radius' } }, + volumeSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00', customData: { units: 'cm^3', calc: 'volume' } }, + + // Others + freeTextSettings: { borderColor: '#222222', opacity: 1, customData: { template: 'comment', mentions: ['qa'] } }, + inkAnnotationSettings: { strokeColor: '#0000ff', thickness: 3, opacity: 0.8, customData: { tool: 'pen', userId: 12345 } }, + stampSettings: { opacity: 0.9, customData: { stampType: 'Approved', by: 'Manager' } }, + stickyNotesSettings: { author: 'QA', subject: 'Review', opacity: 1, customData: { channel: 'inbox', unread: true } } +}); + +pdfviewer.appendTo('#PdfViewer'); +``` + +## Retrieve custom data at runtime + +You can access the customData for any annotation through the viewer's annotationCollection. For example, wire a button click to iterate all annotations and read their custom payloads. + +```html + +``` + +```ts +// Assume `pdfviewer` is your PdfViewer instance +document.getElementById('CustomData')?.addEventListener('click', () => { + const annotations = pdfviewer.annotationCollection; + annotations.forEach((a: any) => { + console.log('Annotation', a.id, 'customData:', a.customData); + }); +}); +``` + +### Notes +- customData can be any JSON-serializable object and is stored with the annotation. +- Use default annotationSettings.customData for global defaults and override with per-tool settings as needed. + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../annotations/create-modify-annotation) +- [Customize Annotation](../annotations/customize-annotation) +- [Remove Annotation](../annotations/delete-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation Permission](../annotations/annotation-permission) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation API](../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/custom-tools.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/custom-tools.md new file mode 100644 index 000000000..9064a7e41 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/custom-tools.md @@ -0,0 +1,171 @@ +--- +layout: post +title: Custom annotation tools in React PDF Viewer | Syncfusion +description: Learn how to build a custom toolbar for Syncfusion React PDF Viewer and switch annotation tools programmatically using setAnnotationMode. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Custom annotation tools in React PDF Viewer + +PDF viewer allows to add your own toolbar and toggle PDF annotation tools programmatically using the setAnnotationMode method. You can enable tools such as Highlight, Underline, Rectangle, Circle, Arrow, Free Text, Ink, and Measurement annotations (Distance, Perimeter, Area, Radius). + +Follow these steps to build a minimal custom annotation toolbar. + +Step 1: Start from a basic PDF Viewer sample + +See the [Getting started guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/javascript-es6/getting-started) to create a basic sample. + +Step 2: Add HTML for a lightweight custom toolbar + +Add buttons for the tools you want to expose. You can use plain buttons or Syncfusion Toolbar. Below is a plain-HTML variant that keeps things simple. + +```html +
+ + + + + + + + + + + + + + + + +
+
+``` + +Step 3: Import and inject modules + +Make sure the Annotation module is injected. If you also want text selection/search, include those as needed. + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch); + +let pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib' +}); +pdfviewer.appendTo('#PdfViewer'); + +// Wire up custom annotation tools using setAnnotationMode +const bindAnnoTools = () => { + const setMode = (mode: string) => pdfviewer.annotationModule.setAnnotationMode(mode as any); + + document.getElementById('toolHighlight')?.addEventListener('click', () => setMode('Highlight')); + document.getElementById('toolUnderline')?.addEventListener('click', () => setMode('Underline')); + document.getElementById('toolStrike')?.addEventListener('click', () => setMode('Strikethrough')); + document.getElementById('toolRectangle')?.addEventListener('click', () => setMode('Rectangle')); + document.getElementById('toolCircle')?.addEventListener('click', () => setMode('Circle')); + document.getElementById('toolLine')?.addEventListener('click', () => setMode('Line')); + document.getElementById('toolArrow')?.addEventListener('click', () => setMode('Arrow')); + document.getElementById('toolPolygon')?.addEventListener('click', () => setMode('Polygon')); + document.getElementById('toolFreeText')?.addEventListener('click', () => setMode('FreeText')); + document.getElementById('toolInk')?.addEventListener('click', () => setMode('Ink')); + document.getElementById('toolSticky')?.addEventListener('click', () => setMode('StickyNotes')); + // Measurement tools + document.getElementById('toolDistance')?.addEventListener('click', () => setMode('Distance')); + document.getElementById('toolPerimeter')?.addEventListener('click', () => setMode('Perimeter')); + document.getElementById('toolArea')?.addEventListener('click', () => setMode('Area')); + document.getElementById('toolRadius')?.addEventListener('click', () => setMode('Radius')); + + // Exit drawing mode + document.getElementById('toolNone')?.addEventListener('click', () => setMode('None')); +}; + +bindAnnoTools(); +``` + +## Custom Tools Using Syncfusion Toolbar for a richer UI + +You can replace the plain buttons with Syncfusion EJ2 Toolbar items and icons similar to the custom toolbar sample. Here is a compact example showing a few common tools. Add the Toolbar package (@syncfusion/ej2-navigations) and wire each item’s click to setAnnotationMode. + +```ts +import { Toolbar as Tool, ClickEventArgs, ItemModel } from '@syncfusion/ej2-navigations'; + +// Add built-in icon classes via EJ2 CSS (match your version), for example: +// + +const items: ItemModel[] = [ + { text: 'Highlight', id: 'annHighlight', tooltipText: 'Highlight', prefixIcon: 'e-pv-highlight-icon' }, + { text: 'Underline', id: 'annUnderline', tooltipText: 'Underline', prefixIcon: 'e-pv-underline-icon' }, + { text: 'Strike', id: 'annStrike', tooltipText: 'Strikethrough', prefixIcon: 'e-pv-strikethrough-icon' }, + { type: 'Separator' }, + { text: 'Rect', id: 'annRect', tooltipText: 'Rectangle', prefixIcon: 'e-pv-shape-rectangle-icon' }, + { text: 'Circle', id: 'annCircle', tooltipText: 'Circle', prefixIcon: 'e-pv-shape-circle-icon' }, + { text: 'Line', id: 'annLine', tooltipText: 'Line', prefixIcon: 'e-pv-shape-line-icon' }, + { text: 'Arrow', id: 'annArrow', tooltipText: 'Arrow', prefixIcon: 'e-pv-shape-arrow-icon' }, + { text: 'Polygon', id: 'annPolygon', tooltipText: 'Polygon', prefixIcon: 'e-pv-shape-pentagon' }, + { type: 'Separator' }, + { text: 'Free Text', id: 'annFreeText', tooltipText: 'Free Text', prefixIcon: 'e-pv-freetext-icon' }, + { text: 'Ink', id: 'annInk', tooltipText: 'Ink', prefixIcon: 'e-pv-inkannotation-icon' }, + { text: 'Note', id: 'annSticky', tooltipText: 'Sticky Note', prefixIcon: 'e-pv-sticky-notes' }, + { type: 'Separator' }, + { text: 'Distance', id: 'annDistance', tooltipText: 'Distance', prefixIcon: 'e-pv-calibrate-distance-icon' }, + { text: 'Perimeter', id: 'annPerimeter', tooltipText: 'Perimeter', prefixIcon: 'e-pv-calibrate-perimeter-icon' }, + { text: 'Area', id: 'annArea', tooltipText: 'Area', prefixIcon: 'e-pv-calibrate-area-icon' }, + { text: 'Radius', id: 'annRadius', tooltipText: 'Radius', prefixIcon: 'e-pv-calibrate-radius-icon' }, + { type: 'Separator' }, + { text: 'Exit', id: 'annNone', tooltipText: 'Exit drawing', align: 'Right' } +]; + +const annoToolbar = new Tool({ + items, + overflowMode: 'Scrollable', + clicked: (args: ClickEventArgs) => { + switch (args.item.id) { + case 'annHighlight': pdfviewer.annotationModule.setAnnotationMode('Highlight'); break; + case 'annUnderline': pdfviewer.annotationModule.setAnnotationMode('Underline'); break; + case 'annStrike': pdfviewer.annotationModule.setAnnotationMode('Strikethrough'); break; + case 'annRect': pdfviewer.annotationModule.setAnnotationMode('Rectangle'); break; + case 'annCircle': pdfviewer.annotationModule.setAnnotationMode('Circle'); break; + case 'annLine': pdfviewer.annotationModule.setAnnotationMode('Line'); break; + case 'annArrow': pdfviewer.annotationModule.setAnnotationMode('Arrow'); break; + case 'annPolygon': pdfviewer.annotationModule.setAnnotationMode('Polygon'); break; + case 'annFreeText': pdfviewer.annotationModule.setAnnotationMode('FreeText'); break; + case 'annInk': pdfviewer.annotationModule.setAnnotationMode('Ink'); break; + case 'annSticky': pdfviewer.annotationModule.setAnnotationMode('StickyNotes'); break; + case 'annDistance': pdfviewer.annotationModule.setAnnotationMode('Distance'); break; + case 'annPerimeter': pdfviewer.annotationModule.setAnnotationMode('Perimeter'); break; + case 'annArea': pdfviewer.annotationModule.setAnnotationMode('Area'); break; + case 'annRadius': pdfviewer.annotationModule.setAnnotationMode('Radius'); break; + case 'annNone': pdfviewer.annotationModule.setAnnotationMode('None'); break; + } + } +}); +annoToolbar.appendTo('#annotationToolbar'); +``` + +Notes + +- setAnnotationMode accepts the annotation type name. Common values include: Highlight, Underline, Strikethrough, StickyNotes, FreeText, Ink, Rectangle, Circle, Line, Arrow, Polygon, Polyline, Distance, Perimeter, Area, Radius, and None to exit. +- You can predefine default annotation styles using the corresponding settings properties (for example, areaSettings as shown in the Area annotation topic). +- To combine with a fully custom viewer toolbar, see Custom Toolbar in React PDF Viewer. + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../annotations/create-modify-annotation) +- [Customize Annotation](../annotations/customize-annotation) +- [Remove Annotation](../annotations/delete-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation Permission](../annotations/annotation-permission) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation API](../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/customize-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/customize-annotation.md new file mode 100644 index 000000000..94630b11f --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/customize-annotation.md @@ -0,0 +1,246 @@ +--- +layout: post +title: Customize annotations in React PDF Viewer | Syncfusion +description: Learn how to customize PDF annotations in Syncfusion React PDF Viewer using UI tools and programmatic settings (defaults and runtime edits). +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Customize annotations in React PDF Viewer + +You can customize annotation color, stroke color, thickness, opacity, and other properties using the built‑in UI or via code. This page summarizes common customization patterns and shows how to set defaults per annotation type. + +## Customize via UI + +Use the annotation toolbar after selecting an annotation: +- Edit Color: changes the annotation fill/text color +![Edit color](../images/edit_color.png) +- Edit Stroke Color: changes border/line color (shapes and lines) +![Edit stroke color](../images/shape_strokecolor.png) +- Edit Thickness: adjusts border/line thickness +![Edit thickness](../images/shape_thickness.png) +- Edit Opacity: adjusts transparency +![Edit opacity](../images/shape_opacity.png) + +Type‑specific options (for example, Line Properties) are available from the context menu (right‑click > Properties) where supported. + +## Set default properties during initialization + +You can set defaults for specific annotation types when creating the PdfViewer instance. You can set author, subject, color, opacity using Annotation Settings. Below are examples using settings already used in the annotation type pages. + +TextMarkup Annotations: + +- Highlight : Set default properties before creating the control using [`highlightSettings`](./annotation-types/highlight-annotation/#set-default-properties-during-control-initialization) +- Strikethrough: Use [`strikethroughSettings`](./annotation-types/strikethrough-annotation/#default-strikethrough-settings-during-initialization) +- Underline: Use [`underlineSettings`](./annotation-types/underline-annotation/#default-underline-settings-during-initialization) +- Squiggly: Use [`squigglySettings`](./annotation-types/Squiggly-annotation/#set-default-properties-during-control-initialization) + +Shape Annotations: + +- Line: Use [`lineSettings`](./annotation-types/line-annotation/#default-line-settings-during-initialization) +- Arrow: Use [`arrowSettings`](./annotation-types/arrow-annotation/#default-arrow-settings-during-initialization) +- Rectangle: Use [`rectangleSettings`](./annotation-types/rectangle-annotation/#default-rectangle-settings-during-initialization) +- Circle : Use [`circleSettings`](./annotation-types/circle-annotation/#default-circle-settings-during-initialization) +- Polygon: Use [`polygonSettings`](./annotation-types/polygon-annotation/#default-polygon-settings-during-initialization) + +Measurement Annotations: + +- Distance: Use [`distanceSettings`](./annotation-types/distance-annotation/#default-distance-settings-during-initialization) +- Perimeter: Use [`perimeterSettings`](./annotation-types/perimeter-annotation/#default-perimeter-settings-during-initialization) +- Area: Use [`areaSettings`](./annotation-types/area-annotation/#default-area-settings-during-initialization) +- Radius: Use [`radiusSettings`](./annotation-types/radius-annotation/#default-radius-settings-during-initialization) +- Volume: Use [`volumeSettings`](./annotation-types/volume-annotation/#default-volume-settings-during-initialization) + +Other Annotations: + +- Redaction: Use [`redactionSettings`](./annotation-types/redaction-annotation/#default-redaction-settings-during-initialization) +- Free Text: Use [`freeTextSettings`](./annotation-types/free-text-annotation/#default-free-text-settings-during-initialization) +- Ink (Freehand): Use [`inkAnnotationSettings`](./annotation-types/ink-annotation/#default-ink-settings-during-initialization) +- Stamp: Use [`stampSettings`](./annotation-types/stamp-annotation/#default-stamp-settings-during-initialization) +- Sticky Notes: Use [`stickyNotesSettings`](./annotation-types/sticky-notes-annotation/#default-sticky-notes-settings-during-initialization) + +Set defaults for specific annotation types when creating the PdfViewer instance. Below are examples using settings already used in the annotation type pages. + +{% tabs %} +{% highlight ts tabtitle="Standalone" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormDesigner, FormFields } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation, FormDesigner, FormFields); + +const pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib", + // Text markup defaults + highlightSettings: { author: 'QA', subject: 'Review', color: '#ffff00', opacity: 0.6 }, + strikethroughSettings: { author: 'QA', subject: 'Remove', color: '#ff0000', opacity: 0.6 }, + underlineSettings: { author: 'Guest User', subject: 'Points to be remembered', color: '#00ffff', opacity: 0.9 }, + squigglySettings: { author: 'Guest User', subject: 'Corrections', color: '#00ff00', opacity: 0.9 }, + + // Shapes + lineSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + arrowSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + rectangleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1 }, + circleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1 }, + polygonSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1 }, + + // Measurements + distanceSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + perimeterSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + areaSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00' }, + radiusSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00' }, + volumeSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00' }, + + // Others + freeTextSettings: { borderColor: '#222222', thickness: 1, opacity: 1 }, + inkAnnotationSettings: { color: '#0000ff', thickness: 3, opacity: 0.8 }, + stampSettings: { opacity: 0.9 }, + stickyNotesSettings: { author: 'QA', subject: 'Review', color: '#ffcc00', opacity: 1 } +}); + +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% highlight ts tabtitle="Server-Backed" %} +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation } from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject(Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, Annotation); + +const pdfviewer: PdfViewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + + highlightSettings: { author: 'QA', subject: 'Review', color: '#ffff00', opacity: 0.6 }, + strikethroughSettings: { author: 'QA', subject: 'Remove', color: '#ff0000', opacity: 0.6 }, + underlineSettings: { author: 'Guest User', subject: 'Points to be remembered', color: '#00ffff', opacity: 0.9 }, + squigglySettings: { author: 'Guest User', subject: 'Corrections', color: '#00ff00', opacity: 0.9 }, + + lineSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + arrowSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + rectangleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1 }, + circleSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1 }, + polygonSettings: { fillColor: '#ffffff00', strokeColor: '#222222', thickness: 1, opacity: 1 }, + + distanceSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + perimeterSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8 }, + areaSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00' }, + radiusSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00' }, + volumeSettings: { strokeColor: '#0066ff', thickness: 2, opacity: 0.8, fillColor: '#ffffff00' }, + + freeTextSettings: { borderColor: '#222222', thickness: 1, opacity: 1 }, + inkAnnotationSettings: { color: '#0000ff', thickness: 3, opacity: 0.8 }, + stampSettings: { opacity: 0.9 }, + stickyNotesSettings: { author: 'QA', subject: 'Review', color: '#ffcc00', opacity: 1 } +}); + +pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/'; +pdfviewer.appendTo('#PdfViewer'); +{% endhighlight %} +{% endtabs %} + +N> After changing defaults using UI tools (Edit Color, Edit Opacity, etc.), the values will reflect the latest selection for subsequent annotations in the same session. + +## Customize programmatically at runtime + +To update an existing annotation from code, modify its properties and call editAnnotation. + +Example: bulk‑update matching annotations. + +```html + +``` +```ts +// Requires a PdfViewer instance named `pdfviewer` +document.getElementById('bulkUpdateAnn')?.addEventListener('click', () => { + for (let i = 0; i < pdfviewer.annotationCollection.length; i++) { + const ann = pdfviewer.annotationCollection[i]; + // Example criteria; customize as needed + if (ann.author === 'Guest' || ann.subject === 'Rectangle') { + ann.color = '#ff0000'; + ann.opacity = 0.8; + // For shapes/lines you can also change strokeColor/thickness when applicable + // ann.strokeColor = '#222222'; + // ann.thickness = 2; + pdfviewer.annotation.editAnnotation(ann); + } + } +}); +``` + +## Customize Annotation Settings + +Defines the settings of the annotations. You can change annotation settings like author name, height, width etc., using [annotationSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationsettings) API + +```html +
+``` +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, TextSearch, Print, Annotation, FormFields, FormDesigner } from '@syncfusion/ej2-pdfviewer'; + + PdfViewer.Inject(Toolbar,Magnification,Navigation, LinkAnnotation,ThumbnailView,BookmarkView, + TextSelection, TextSearch, Print, Annotation,FormFields, FormDesigner); + + let viewer: PdfViewer = new PdfViewer(); + viewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; + viewer.documentPath = "PDF_Succinctly.pdf"; + // Change the annotation settings. + viewer.annotationSettings = { + author: 'XYZ', + minHeight: 10, + minWidth: 10, + maxWidth: 100, + maxHeight: 100, + isLock: false, + skipPrint: false, + skipDownload: false, + allowedInteractions: [AllowedInteraction.Select, AllowedInteraction.Move] + }; + viewer.appendTo('#PdfViewer'); +``` +## Customize Annotation SelectorSettings + +Defines the settings of annotation selector. You can customize the annotation Selector using [annotationSelectorSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#annotationselectorsettings) API + +```html +
+``` +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, TextSearch, Print, Annotation, FormFields, FormDesigner, AnnotationResizerLocation, CursorType } from '@syncfusion/ej2-pdfviewer'; + + PdfViewer.Inject(Toolbar,Magnification,Navigation, LinkAnnotation,ThumbnailView,BookmarkView, + TextSelection, TextSearch, Print, Annotation,FormFields,FormDesigner); + + let viewer: PdfViewer = new PdfViewer(); + viewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib"; + viewer.documentPath = "PDF_Succinctly.pdf"; + // Change the annotation selector settings. + viewer.annotationSelectorSettings = { + selectionBorderColor: 'blue', + resizerBorderColor: 'red', + resizerFillColor: '#4070ff', + resizerSize: 8, + selectionBorderThickness: 1, + resizerShape: 'Circle', + selectorLineDashArray: [5, 6], + resizerLocation: AnnotationResizerLocation.Corners | AnnotationResizerLocation.Edges, + resizerCursorType: CursorType.grab + }; + viewer.appendTo('#PdfViewer'); +``` + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../annotations/create-modify-annotation) +- [Remove Annotation](../annotations/delete-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation Permission](../annotations/annotation-permission) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation API](../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/delete-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/delete-annotation.md new file mode 100644 index 000000000..0f018f3d0 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/delete-annotation.md @@ -0,0 +1,104 @@ +--- +layout: post +title: Remove annotations in React PDF Viewer | Syncfusion +description: Learn how to remove/delete PDF annotations in Syncfusion React PDF Viewer using UI options (context menu, toolbar, Delete key) and programmatic APIs. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Remove annotations in React PDF Viewer + +You can remove annotations using the built-in UI or programmatically. This page shows the common ways to delete annotations in the viewer. + +## Delete via UI + +You can delete a selected annotation in three ways: +- Context menu: Right-click the annotation and choose Delete. +![Delete via context menu](../annotations/annotation-images/delete-annot-context-menu.png) +- Secondary toolbar: Select the annotation and click the Delete button on the annotation toolbar. +![Delete via annotation toolbar](../annotations/annotation-images/delete-annot.png) +- Keyboard: Select the annotation and press the `Delete` key. + +## Delete programmatically + +You can delete the currently selected annotation, or delete a specific annotation by its id. + +```html +
+ + +
+
+``` +```ts +import { + PdfViewer, + Toolbar, + Magnification, + Navigation, + LinkAnnotation, + ThumbnailView, + BookmarkView, + TextSelection, + TextSearch, + Print, + Annotation, + FormFields, + FormDesigner +} from '@syncfusion/ej2-pdfviewer'; + +PdfViewer.Inject( + Toolbar, + Magnification, + Navigation, + LinkAnnotation, + ThumbnailView, + BookmarkView, + TextSelection, + TextSearch, + Print, + Annotation, + FormFields, + FormDesigner +); + +// Create viewer +const viewer = new PdfViewer({ + documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf', + // Standalone resources + resourceUrl: 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib', +}); +viewer.appendTo('#PdfViewer'); + +document.getElementById('del')?.addEventListener('click', () => { + // Delete the selected annotation + viewer.annotation.deleteAnnotation(); +}); + +document.getElementById('delbyId')?.addEventListener('click', () => { + // Delete the first annotation using its id from the annotation collection + if (viewer.annotationCollection.length > 0) { + viewer.annotation.deleteAnnotationById(viewer.annotationCollection[0].id); + } +}); +``` + +N> Deleting via API requires the annotation to exist in the current document. Ensure an annotation is selected when using deleteAnnotation(), or pass a valid id to deleteAnnotationById(). + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../overview) +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../annotations/create-modify-annotation) +- [Customize Annotation](../annotations/customize-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation Permission](../annotations/annotation-permission) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation API](../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/export-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/export-annotation.md new file mode 100644 index 000000000..06f5d586f --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/export-annotation.md @@ -0,0 +1,134 @@ +--- +layout: post +title: Export annotations in React PDF Viewer | Syncfusion +description: Learn how to Export annotations in Syncfusion React PDF Viewer using UI options and programmatic APIs. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Export annotations in React PDF Viewer + +PDF Viewer provides support to export annotations. You can export annotations from the PDF Viewer in two ways: + +- Using the built-in UI in the Comments panel (JSON or XFDF file) +- Programmatically (JSON, XFDF, or as an object for custom handling) + +## Export using the UI (Comments panel) + +The Comments panel provides export actions in its overflow menu: + +- Export annotation to JSON file +- Export annotation to XFDF file + +Follow the steps to export annotations: + +1. Open the Comments panel in the PDF Viewer. +2. Click the overflow menu (three dots) at the top of the panel. +3. Choose Export annotation to JSON file or Export annotation to XFDF file. + +This generates and downloads the selected format containing all annotations in the current document. + +![Export Annotation](../annotation-images/export-annot.png) + +## Export programmatically + +You can export annotations from code using [exportAnnotation](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#exportannotation) ,[exportAnnotationsAsObject](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#exportannotationsasobject) and [exportAnnotationsAsBase64String](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#exportannotationsasbase64string) APIs. + +Use the following end-to-end example to initialize the viewer and export annotations as JSON, XFDF, or as an object. + +```html + +
+
+ + + + +
+``` + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, TextSearch, Print, Annotation, FormFields, FormDesigner, AllowedInteraction, AnnotationDataFormat } from '@syncfusion/ej2-pdfviewer'; + +// Inject required modules +PdfViewer.Inject( + Toolbar, + Magnification, + Navigation, + LinkAnnotation, + ThumbnailView, + BookmarkView, + TextSelection, + TextSearch, + Print, + Annotation, + FormFields, + FormDesigner +); + +// Initialize the viewer +let viewer: PdfViewer = new PdfViewer(); +viewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +viewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +viewer.appendTo('#pdfViewer'); + +// Wire up export actions + +//Export Annotation as JSON +const btnJson = document.getElementById('ExportJSON'); +btnJson?.addEventListener('click', () => { + viewer.exportAnnotation(AnnotationDataFormat.Json); +}); + +//Export Annotation As XFDF +const btnXfdf = document.getElementById('ExportXfdf'); +btnXfdf?.addEventListener('click', () => { + viewer.exportAnnotation(AnnotationDataFormat.Xfdf); +}); + +//Export Annotation As Object +const btnObject = document.getElementById('ExportAsObject'); +btnObject?.addEventListener('click', () => { + viewer.exportAnnotationsAsObject().then((value: any) => { + // Persist or transmit the object as needed (DB/API). Keep for future import. + console.log('Exported annotation object:', value); + }); +}); + +//Export Annotation as Base 64 +var exportObject1; +document.getElementById('ExportAsBase64')?.addEventListener('click', function () { +viewer.exportAnnotationsAsBase64String(AnnotationDataFormat.Json).then(function (value: any) { + exportObject1 = value; + console.log(exportObject1); + }) + }); +``` + +## Common use cases + +- Archive or share annotations as portable JSON/XFDF files +- Save annotations alongside a document in your storage layer +- Send annotations to a backend for collaboration or review workflows +- Export as object for custom serialization and re-import later + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../../overview) +- [Annotation Types](../../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Import Annotation](../export-import/import-annotation) +- [Import Export Events](../export-import/export-import-events) +- [Annotation Permission](../../annotations/annotation-permission) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/export-import-events.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/export-import-events.md new file mode 100644 index 000000000..7f3ac64b1 --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/export-import-events.md @@ -0,0 +1,70 @@ +--- +layout: post +title: Import/Export events for annotations in React PDF Viewer | Syncfusion +description: Learn how to handle Import/Export events for annotations in the Syncfusion React PDF Viewer component. +platform: document-processing +control: PDF Viewer +documentation: ug +--- + +# Import/Export events for annotations in React PDF Viewer + +Import/Export events let you track and customize the full lifecycle of annotation data flowing into and out of the PDF Viewer. + +Use them to validate inputs, show progress UI, log audit trails, or block operations based on your business rules. Each event exposes typed event-args (ImportStartEventArgs, ImportSuccessEventArgs, ImportFailureEventArgs, ExportStartEventArgs, ExportSuccessEventArgs, ExportFailureEventArgs) describing the operation context. + +## Import events +- [importStart](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#importstart): Triggers when an import operation starts. +- [importSuccess](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#importsuccess): Triggers when annotations are successfully imported. +- [importFailed](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#importfailed): Triggers when importing annotations fails. + +## Handle import events +```ts +viewer.importStart = (args: any) => { + console.log('Import started', args); +}; +viewer.importSuccess = (args: any) => { + console.log('Import success', args); +}; +viewer.importFailed = (args: any) => { + console.error('Import failed', args); +}; +``` + +## Export events +- [exportStart](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#exportstart): Triggers when an export operation starts. +- [exportSuccess](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#exportsuccess): Triggers when annotations are successfully exported. +- [exportFailed](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#exportfailed): Triggers when exporting annotations fails. + +## Handle export events +```ts +viewer.exportStart = (args: any) => { + console.log('Export started', args); +}; +viewer.exportSuccess = (args: any) => { + console.log('Export success', args); +}; +viewer.exportFailed = (args: any) => { + console.error('Export failed', args); +}; +``` + +Notes: +- importStart/importSuccess/importFailed cover the lifecycle of annotation imports. +- exportStart/exportSuccess/exportFailed cover the lifecycle of annotation exports. + +## See also + +- [Annotation Overview](../../overview) +- [Annotation Types](../../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export Annotation](../export-import/export-annotation) +- [Import Annotation](../export-import/import-annotation) +- [Annotation Permission](../../annotations/annotation-permission) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/import-annotation.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/import-annotation.md new file mode 100644 index 000000000..231525fcb --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/export-import/import-annotation.md @@ -0,0 +1,112 @@ +--- +layout: post +title: Import annotations in React PDF Viewer | Syncfusion +description: Learn how to import annotations in Syncfusion React PDF Viewer using UI options and programmatic APIs. +platform: document-processing +control: PDF Viewer +documentation: ug +--- + +# Import annotations in React PDF Viewer + +You can import annotations into the PDF Viewer in two ways: + +- Using the built-in UI in the Comments panel (import JSON or XFDF files) +- Programmatically by passing an annotation object exported from the viewer + +## Import using the UI (Comments panel) + +The Comments panel provides import options in its overflow menu: + +- Import annotations from JSON file +- Import annotations from XFDF file + +Steps: +1. Open the Comments panel in the PDF Viewer. +2. Click the overflow menu (three dots) at the top of the panel. +3. Choose Import annotations from JSON file or Import annotations from XFDF file and pick the file. + +All annotations in the selected file will be applied to the current document. + +![Export Annotation](../annotation-images/import-annot.png) + +## Import programmatically (from object) + +Import annotations from an object previously exported using exportAnnotationsAsObject(). Only objects returned by the viewer can be re-imported using [importAnnotation](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#importannotation) method. + +The following end-to-end example initializes the viewer and wires a button to import annotations from a pasted/exported object. + +```html + + +
+``` + +```ts +import { PdfViewer, Toolbar, Magnification, Navigation, LinkAnnotation, ThumbnailView, BookmarkView, + TextSelection, TextSearch, Print, Annotation, FormFields, FormDesigner, AllowedInteraction } from '@syncfusion/ej2-pdfviewer'; + +// Inject required modules +PdfViewer.Inject( + Toolbar, + Magnification, + Navigation, + LinkAnnotation, + ThumbnailView, + BookmarkView, + TextSelection, + TextSearch, + Print, + Annotation, + FormFields, + FormDesigner +); + +// Initialize the viewer +let viewer: PdfViewer = new PdfViewer(); +viewer.resourceUrl = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib'; +viewer.documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf'; +viewer.appendTo('#pdfViewer'); + +//Exported Annotation as Object +var exportedObject: string; +const btnObject = document.getElementById('ExportAsObject'); +btnObject?.addEventListener('click', () => { + viewer.exportAnnotationsAsObject().then((value: any) => { + // Persist or transmit the object as needed (DB/API). Keep for future import. + console.log('Exported annotation object:', value); + exportedObject=value; + }); +}); + +// Import from an exported object pasted in the textarea +const btnImport = document.getElementById('ImportFromObject'); +btnImport?.addEventListener('click', () => { + viewer.importAnnotation(JSON.parse(exportedObject)); +}); +``` + +## Common use cases + +- Restore annotations saved earlier (e.g., from a database or API) +- Apply reviewer annotations shared as JSON/XFDF files via the Comments panel +- Migrate or merge annotations between documents or sessions +- Support collaborative workflows by reloading team annotations + +[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master) + +## See also + +- [Annotation Overview](../../overview) +- [Annotation Types](../../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../../annotations/create-modify-annotation) +- [Customize Annotation](../../annotations/customize-annotation) +- [Remove Annotation](../../annotations/delete-annotation) +- [Handwritten Signature](../../annotations/signature-annotation) +- [Export Annotation](../export-import/export-annotation) +- [Import Export Events](../export-import/export-import-events) +- [Annotation Permission](../../annotations/annotation-permission) +- [Annotation in Mobile View](../../annotations/annotations-in-mobile-view) +- [Annotation Events](../../annotations/annotation-event) +- [Annotation API](../../annotations/annotations-api) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/react/annotation/overview.md b/Document-Processing/PDF/PDF-Viewer/react/annotation/overview.md new file mode 100644 index 000000000..b85e521df --- /dev/null +++ b/Document-Processing/PDF/PDF-Viewer/react/annotation/overview.md @@ -0,0 +1,51 @@ +--- +layout: post +title: Overview of Annotation in React PDF Viewer control | Syncfusion +description: Learn about Annotations and how to add, edit, delete, and configure Annotations in the Syncfusion React PDF Viewer. +platform: document-processing +control: PDF Viewer +documentation: ug +domainurl: ##DomainURL## +--- + +# Annotations overview in React PDF Viewer + +Annotations in PDFViewer are interactive elements that allow users to add notes, highlights, or text boxes directly to a PDF document. These annotations can be used to add context or feedback directly to PDF files, simplifying collaboration during document reviews. + +The PDF Viewer component provides a complete set of annotation tools for reviewing, measuring, and marking up PDFs in JavaScript (ES6). + +## Supported annotations + +- Text markup: [Highlight](../annotations/annotation-types/highlight-annotation), [Underline](../annotations/annotation-types/underline-annotation), [Squiggly](../annotations/annotation-types/Squiggly-annotation), [Strikethrough](../annotations/annotation-types/strikethrough-annotation) +- Shapes: [Line](../annotations/annotation-types/line-annotation), p[Arrow](../annotations/annotation-types/arrow-annotation), [Rectangle](../annotations/annotation-types/rectangle-annotation), [Circle](../annotations/annotation-types/circle-annotation), [Polygon](../annotations/annotation-types/polygon-annotation) +- Text boxes: [Free Text](../annotations/annotation-types/free-text-annotation) +- Drawing: [Ink](../annotations/annotation-types/ink-annotation) (freehand) +- Stamps: [Standard and custom stamps](../annotations/annotation-types/stamp-annotation) +- Notes: [Sticky Notes](../annotations/annotation-types/sticky-notes-annotation) (comments) +- Redaction: Mark and apply [redactions](../annotations/annotation-types/redaction-annotation) +- Measurement: [Distance](../annotations/annotation-types/distance-annotation), [Perimeter](../annotations/annotation-types/perimeter-annotation), [Area](../annotations/annotation-types/area-annotation), [Radius](../annotations/annotation-types/radius-annotation), [Volume](../annotations/annotation-types/volume-annotation) + +## Annotation manipulation capabilities + +- [Create annotations](../annotations/create-modify-annotation): Use the toolbar, context menu, or APIs to add highlights, notes, shapes, and more directly onto the PDF document. +- [Edit annotations](../annotations/create-modify-annotation.md): Modify existing annotations by moving, resizing, or updating text and style properties like color, opacity, and thickness. +- [Customize annotations](../annotations/customize-annotation): Adjust appearance and behavior—such as fonts, fill colors, and opacity—through the UI or configuration options. +- [Undo and redo annotations](../annotations/annotations-undo-redo): Revert or reapply annotation actions (add, edit, delete) using toolbar buttons or corresponding APIs. +- [Import and export annotations](../annotations/export-import/export-annotation): Save and load annotations in JSON or XFDF formats to persist markups across sessions or share them with others. +- Set [Permissions](../annotations/annotation-permission): Enable or disable annotation permission, ensuring compliance with document permissions. +- Add and manage [comments](../annotations/comments): Insert, edit, and delete comments or sticky notes attached to annotations for clearer feedback and collaboration. + +## See also + +- [Annotation Types](../annotations/annotation-types/area-annotation) +- [Annotation Toolbar](../toolbar-customization/annotation-toolbar) +- [Create and Modify Annotation](../annotations/create-modify-annotation) +- [Customize Annotation](../annotations/customize-annotation) +- [Remove Annotation](../annotations/delete-annotation) +- [Handwritten Signature](../annotations/signature-annotation) +- [Export and Import Annotation](../annotations/export-import/export-annotation) +- [Annotation Permission](../annotations/annotation-permission) +- [Annotation in Mobile View](../annotations/annotations-in-mobile-view) +- [Annotation Events](../annotations/annotation-event) +- [Annotation Undo Redo](../annotations/annotations-undo-redo) +- [Annotation API](../annotations/annotations-api) \ No newline at end of file