- Home
- Forum
- Angular - EJ 2
- Add a FreeText annotation programmatically
Add a FreeText annotation programmatically
Hi,
Can you tell me how to add FreeText annotation in our PDF viewer programmatically? Let's say I have a custom button in my application and clicking the button should add the free text annotation at specific location in the PDF viewer.
Let me know.
Thanks
Refer the below code snippet and sample to add the free text annotation at a specific location in the PDF viewer.
Code snippet:
|
addFreeText() { var pdfViewer = (<any>document.getElementById('pdfViewer')) .ej2_instances[0]; pdfViewer.annotation.addAnnotation("FreeText", { offset: {x: 100, y: 100}, fontSize:16, fontFamily: "Helvetica", pageNumber: 1, width: 200, height: 40, isLock: false, defaultText: "Syncfusion", }) } |
Thanks for your reply.
- Is there anyway to get the annotation ID of the newly added free text annotation?
I can loop through the annotation collection and get the free text annotation. But if there are multiple free text annotations added at the same time, how we can identify the one which we added now.
or is it possible to pass some ID while creating new free text annotation? - How to update the content of an existing Free text annotation programmatically.
- How to move the free text annotation programmatically.
Find the details for the respective queries
|
Is there anyway to get the annotation ID of the newly
added free text annotation? |
Yes, while adding the annotation in the PDF Viewer annotationAdd event is triggered by using this event you can get the newly added annotation id. Refer the below code snippet and sample to get the newly added free text annotation id in the console.
|
|
|
How to update the content of an existing Free text annotation programmatically. |
Refer the below code snippet and sample to change the content of an existing Free text annotation programmatically.
Code snippet:
|
|
|
How to move the free text annotation programmatically. |
Refer the below code snippet and sample to move
the free text annotation programmatically.
|
- 3 Replies
- 2 Participants
-
SR Sriraman
- Dec 29, 2022 09:38 AM UTC
- Jan 3, 2023 04:57 PM UTC