Link Annotation in Vue PDF Viewer
25 Sep 202613 minutes to read
This guide explains how to enable, add, customize, and manage link annotations in the Syncfusion Vue PDF Viewer. Link annotations can navigate to another page in the same PDF or open an external URL in the browser.

Enable Link Annotation in the Viewer
To enable link annotations, inject the following modules into the Vue PDF Viewer:
<template>
<div id="app">
<ejs-pdfviewer id="pdfViewer" ref="pdfviewer" :documentPath="documentPath" :resourceUrl="resourceUrl"
:hyperlinkOpenState="hyperlinkOpenState">
</ejs-pdfviewer>
</div>
</template>
<script setup>
import {
PdfViewerComponent as EjsPdfviewer,
Toolbar,
Magnification,
Navigation,
LinkAnnotation,
BookmarkView,
Annotation,
ThumbnailView,
Print,
TextSelection,
TextSearch,
FormFields,
FormDesigner,
PageOrganizer
} from '@syncfusion/ej2-vue-pdfviewer';
import { provide } from 'vue';
const documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
const resourceUrl = 'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
const hyperlinkOpenState = 'NewTab';
provide('PdfViewer', [
Toolbar,
Magnification,
Navigation,
LinkAnnotation,
BookmarkView,
Annotation,
ThumbnailView,
Print,
TextSelection,
TextSearch,
FormFields,
FormDesigner,
PageOrganizer
]);
</script><template>
<div id="app">
<ejs-pdfviewer id="pdfViewer" ref="pdfviewer" :documentPath="documentPath" :resourceUrl="resourceUrl"
:hyperlinkOpenState="hyperlinkOpenState">
</ejs-pdfviewer>
</div>
</template>
<script>
import {
PdfViewerComponent,
Toolbar,
Magnification,
Navigation,
LinkAnnotation,
BookmarkView,
Annotation,
ThumbnailView,
Print,
TextSelection,
TextSearch,
FormFields,
FormDesigner,
PageOrganizer
} from '@syncfusion/ej2-vue-pdfviewer';
export default {
name: 'App',
components: {
'ejs-pdfviewer': PdfViewerComponent
},
data() {
return {
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib',
hyperlinkOpenState: 'NewTab'
};
},
provide: {
PdfViewer: [
Toolbar,
Magnification,
Navigation,
LinkAnnotation,
BookmarkView,
Annotation,
ThumbnailView,
Print,
TextSelection,
TextSearch,
FormFields,
FormDesigner,
PageOrganizer
]
}
};
</script>The
hyperlinkOpenStateproperty controls how external URLs open when the user clicks a link. UseNewTabto open the URL in a new browser tab orNewWindowto open it in a separate browser window.
Add Link Annotation
Add Link Using the Toolbar
- Click the Add Link button from the annotation toolbar.
- Choose whether the link points to a URL or a Page.
- Enter the target URL or page number.
- Set properties such as stroke color and thickness.
- Click Insert to create the link annotation.


Add Link Annotation Programmatically
Use addAnnotation() to create a link annotation at a specific location.
Add Internal Page Link
<template>
<div id="app">
<button v-on:click="addInternalLink">Add internal page link</button>
<ejs-pdfviewer id="pdfViewer" ref="pdfviewer" :documentPath="documentPath" :resourceUrl="resourceUrl"></ejs-pdfviewer>
</div>
</template>
<script setup>
import { PdfViewerComponent as EjsPdfviewer, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-vue-pdfviewer';
import { provide, ref } from 'vue';
const pdfviewer = ref(null);
const documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
const resourceUrl = 'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
provide('PdfViewer', [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer]);
const addInternalLink = () => {
pdfviewer.value.ej2Instances.annotation.addAnnotation('Link', {
offset: { x: 200, y: 480 },
pageNumber: 1,
width: 150,
height: 75,
destinationPageIndex: 4,
destinationLocation: { x: 100, y: 200 },
zoomValue: 4,
strokeColor: '#1433e3'
});
};
</script>This adds a link rectangle that navigates to page index 4 and zooms to the specified location when clicked.
Add External URL Link
<template>
<div id="app">
<button v-on:click="addExternalLink">Add external link</button>
<ejs-pdfviewer id="pdfViewer" ref="pdfviewer" :documentPath="documentPath" :resourceUrl="resourceUrl"></ejs-pdfviewer>
</div>
</template>
<script setup>
import { PdfViewerComponent as EjsPdfviewer, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-vue-pdfviewer';
import { provide, ref } from 'vue';
const pdfviewer = ref(null);
const documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
const resourceUrl = 'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
provide('PdfViewer', [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer]);
const addExternalLink = () => {
pdfviewer.value.ej2Instances.annotation.addAnnotation('Link', {
offset: { x: 450, y: 480 },
pageNumber: 1,
width: 150,
height: 75,
url: 'https://www.syncfusion.com',
strokeColor: '#FF0000'
});
};
</script>Customize Link Appearance
Link annotations can be customized with visual and navigation properties such as stroke color, thickness, destination page, or URL. The following example configures the viewer to open external links in a separate browser window.
<template>
<div id="app">
<ejs-pdfviewer id="pdfViewer" :documentPath="documentPath" :resourceUrl="resourceUrl" hyperlinkOpenState="NewWindow"></ejs-pdfviewer>
</div>
</template>
<script setup>
import { PdfViewerComponent as EjsPdfviewer, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-vue-pdfviewer';
import { provide } from 'vue';
const documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
const resourceUrl = 'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
provide('PdfViewer', [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer]);
</script>Manage Link Annotations
Edit Link Annotation in the UI
After a link annotation is inserted, the user can:
- Right-click the selected link annotation to open the context menu
- Choose Select and drag the rectangle to a new position
- Resize the rectangle using resize handles
- Right-click again and choose Edit to update the target page or URL


Edit Link Annotation Programmatically
Use editAnnotation() to update an existing link annotation.
<script setup>
import { ref } from 'vue';
const pdfviewer = ref(null);
const editLinkAnnotation = () => {
const viewer = pdfviewer.value.ej2Instances;
for (const linkAnnotation of viewer.annotationCollection) {
if (linkAnnotation.subject === 'Link') {
linkAnnotation.strokeColor = '#1fcbd4';
linkAnnotation.thickness = 2;
linkAnnotation.bounds = { left: 100, top: 100, width: 100, height: 100 };
linkAnnotation.url = 'https://www.google.com';
linkAnnotation.destinationPageIndex = 3;
linkAnnotation.destinationLocation = { x: 300, y: 300 };
linkAnnotation.zoomValue = 1;
viewer.annotation.editAnnotation(linkAnnotation);
break;
}
}
};
</script>Delete Link Annotation
The PDF Viewer supports deleting link annotations through both the UI and API.

Delete a link annotation by ID
<script setup>
import { ref } from 'vue';
const pdfviewer = ref(null);
const deleteLinkById = () => {
const viewer = pdfviewer.value.ej2Instances;
const linkAnnotation = viewer.annotationCollection.find((item) => item.subject === 'Link');
if (linkAnnotation) {
viewer.annotation.deleteAnnotationById(linkAnnotation.annotationId);
}
};
</script>Set Properties While Adding an Individual Link
You can set link properties directly in the addAnnotation('Link', ...) call.
<script setup>
import { ref } from 'vue';
const pdfviewer = ref(null);
const addMultipleLinks = () => {
const viewer = pdfviewer.value.ej2Instances;
viewer.annotation.addAnnotation('Link', {
offset: { x: 100, y: 150 },
pageNumber: 1,
width: 180,
height: 60,
url: 'https://www.syncfusion.com',
strokeColor: '#ff0000'
});
viewer.annotation.addAnnotation('Link', {
offset: { x: 320, y: 180 },
pageNumber: 1,
width: 150,
height: 60,
destinationPageIndex: 2,
destinationLocation: { x: 100, y: 200 },
zoomValue: 2,
strokeColor: '#1433e3'
});
};
</script>Link Annotation Events
The PDF Viewer raises annotation life cycle events that can be used to monitor when link annotations are added, modified, selected, or removed. See Annotation Events.