The PDF Viewer provides the options to add measurement annotations. You can measure the page annotations with the help of measurement annotation. The supported measurement annotations in the PDF Viewer control are:
The measurement annotations can be added to the PDF document using the annotation toolbar.
In the pan mode, if the measurement annotation mode is entered, the PDF Viewer control will switch to text select mode.
Refer to the following code snippet to switch to distance annotation mode.
<template>
<div id="app">
<button id="set">Distance</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('Distance');
});
}
}
}
</script>
The fill color, stroke color, thickness, and opacity of the measurement annotation can be edited using the Edit Color tool, Edit Stroke Color tool, Edit Thickness tool, and Edit Opacity tool in the annotation toolbar.
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 thickness of the border 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 line shapes such as distance and perimeter annotations can be edited using the Line properties window. It can be opened by selecting the Properties option in the context menu that appears on right-clicking the distance and perimeter annotations.
The properties of the shape annotations can be set before creating the control using distanceSettings, perimeterSettings, areaSettings, radiusSettings and volumeSettings. Refer to the following code snippet to set the default annotation settings.
<template>
<div id="app">
<ejs-pdfviewer
id="pdfViewer"
ref="pdfviewer"
:serviceUrl="serviceUrl"
:documentPath="documentPath"
:distanceSettings="distanceSettings"
:perimeterSettings="perimeterSettings"
:areaSettings="areaSettings"
:radiusSettings="radiusSettings"
:volumeSettings="volumeSettings">
</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",
distanceSettings: {fillColor: 'blue', opacity: 0.6, strokeColor: 'green'},
perimeterSettings: {fillColor: 'green', opacity: 0.6, strokeColor: 'blue'},
areaSettings: {fillColor: 'yellow', opacity: 0.6, strokeColor: 'orange'},
radiusSettings: {fillColor: 'orange', opacity: 0.6, strokeColor: 'pink'},
volumeSettings: {fillColor: 'pink', opacity: 0.6, strokeColor: 'yellow'}
};
},
provide: {
PdfViewer: [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
ThumbnailView, Print, TextSelection, TextSearch, Annotation]}
}
</script>
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.
The Units of measurements support for the measurement annotations in the PDF Viewer are
The properties of scale ratio for measurement annotation can be set before creating the control using ScaleRatioSettings as shown in the following code snippet,
<template>
<div id="app">
<ejs-pdfviewer
id="pdfViewer"
ref="pdfviewer"
:serviceUrl="serviceUrl"
:documentPath="documentPath"
:measurementSettings="measurementSettings">
</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",
measurementSettings: {scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm'}
};
},
provide: {
PdfViewer: [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
ThumbnailView, Print, TextSelection, TextSearch, Annotation]}
}
</script>