The PDF Viewer control provides the options to add, edit, and delete the free text annotations.
The Free text annotations can be added to the PDF document using the annotation toolbar.
In the pan mode, if the free text annotation mode is entered, the PDF Viewer control will switch to text select mode.
Refer to the following code sample to switch to the Free Text annotation mode.
<template>
<div id="app">
<button id="set">FreeText</button>
<ejs-pdfviewer
id="pdfViewer"
ref="pdfviewer"
:serviceUrl="serviceUrl"
:documentPath="documentPath"
:documentLoad="documentLoad">
</ejs-pdfviewer>
</div>
</template>
<script>
import Vue from 'vue';
import { PdfViewerPlugin, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
ThumbnailView, Print, TextSelection, TextSearch, Annotation } from '@syncfusion/ej2-vue-pdfviewer';
Vue.use(PdfViewerPlugin);
var viewer;
export default {
name: 'app',
data () {
return {
serviceUrl:"https://ej2services.syncfusion.com/production/web-services/api/pdfviewer",
documentPath:"PDF_Succinctly.pdf"
};
},
provide: {
PdfViewer: [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
ThumbnailView, Print, TextSelection, TextSearch, Annotation]},
methods: {
documentLoad() {
viewer = this.$refs.pdfviewer.ej2Instances;
document.getElementById('set').addEventListener('click', ()=> {
viewer.annotation.setAnnotationMode('FreeText');
});
}
}
}
</script>
The font family, font size, font styles, font color, text alignment, fill color, the border stroke color, border thickness, and opacity of the free text annotation can be edited using the Font Family tool, Font Size tool, Font Color tool, Text Align tool, Font Style tool Edit Color tool, Edit Stroke Color tool, Edit Thickness tool, and Edit Opacity tool in the annotation toolbar.
The font family of the annotation can be edited by selecting the desired font in the Font Family tool.
The font size of the annotation can be edited by selecting the desired size in the Font Size tool.
The font color of the annotation can be edited using the color palette provided in the Font Color tool.
The text in the annotation can be aligned by selecting the desired styles in the drop-down pop-up in the Text Align tool.
The style of the text in the annotation can be edited by selecting the desired styles in the drop-down pop-up in the Font Style tool.
The fill color of the annotation can be edited using the color palette provided in the Edit Color tool.
The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool.
The border thickness of the annotation can be edited using the range slider provided in the Edit Thickness tool.
The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool.
The properties of the free text annotation can be set before creating the control using the FreeTextSettings.
After editing the default values, they will be changed to the selected values. Refer to the following code sample to set the default free text annotation settings.
<template>
<div id="app">
<ejs-pdfviewer
id="pdfViewer"
ref="pdfviewer"
:serviceUrl="serviceUrl"
:documentPath="documentPath"
:freeTextSettings="freetextSettings">
</ejs-pdfviewer>
</div>
</template>
<script>
import Vue from 'vue';
import { PdfViewerPlugin, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
ThumbnailView, Print, TextSelection, TextSearch, Annotation, SignStampItem } from '@syncfusion/ej2-vue-pdfviewer';
Vue.use(PdfViewerPlugin);
var viewer;
export default {
name: 'app',
data () {
return {
serviceUrl:"https://ej2services.syncfusion.com/production/web-services/api/pdfviewer",
documentPath:"PDF_Succinctly.pdf",
freetextSettings: {fillColor: 'green', borderColor: 'blue', fontColor: 'yellow'}
};
},
provide: {
PdfViewer: [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
ThumbnailView, Print, TextSelection, TextSearch, Annotation]}
}
</script>