How can I help you?
Line Annotation (Shape) in Angular PDF Viewer
26 Mar 20269 minutes to read
Line annotations allow users to draw straight connectors or callouts on PDFs for markup, review, diagrams, or measurement guides. They support customization of color, thickness, opacity, and arrowheads, and can be edited, resized, deleted, or exported along with the document.

Enable Line Annotation in the Viewer
To enable Line annotations, inject the following modules into the Angular PDF Viewer:
import { Component } from '@angular/core';
import {
PdfViewerModule,
ToolbarService,
AnnotationService
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<ejs-pdfviewer
id="pdfViewer"
[documentPath]="document"
[resourceUrl]="resource"
style="height:650px;display:block">
</ejs-pdfviewer>
</div>
`,
imports: [PdfViewerModule],
providers: [ToolbarService, AnnotationService]
})
export class AppComponent {
public document: string =
'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string =
'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
}Add Line Annotation
Add Line Annotation Using the Toolbar
- Open the Annotation Toolbar.
- Select Shapes → Line.
- Click and drag on the PDF page to draw the line.

Note: When in Pan mode, selecting a shape tool automatically switches the viewer to selection mode for smooth interaction.
Enable Line Mode
Switch the viewer into line mode using setAnnotationMode('Line').
enableLineMode(): void {
const pdfViewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
pdfViewer.annotationModule.setAnnotationMode('Line');
}Exit Line Mode
Switch back to normal mode using:
exitLineMode(): void {
const pdfViewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
pdfViewer.annotationModule.setAnnotationMode('None');
}Add Line Programmatically
You can add line annotations using the addAnnotation API.
addLine(): void {
const pdfViewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
pdfViewer.annotation.addAnnotation('Line', {
offset: { x: 200, y: 230 },
pageNumber: 1,
vertexPoints: [
{ x: 200, y: 230 },
{ x: 350, y: 230 }
]
});
}Customize Line Appearance
Configure default line appearance using the lineSettings property.
import { Component } from '@angular/core';
import {
PdfViewerModule,
ToolbarService,
AnnotationService
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<ejs-pdfviewer
id="pdfViewer"
[documentPath]="document"
[resourceUrl]="resource"
[lineSettings]="lineSettings"
style="height:650px;display:block">
</ejs-pdfviewer>
</div>
`,
imports: [PdfViewerModule],
providers: [ToolbarService, AnnotationService]
})
export class AppComponent {
public document: string =
'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string =
'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
public lineSettings = {
strokeColor: '#0066ff',
thickness: 2,
opacity: 0.9
};
}NOTE
Fill color is available only when an arrowhead style is applied at the Start or End of the line. If both are set to
None, the Fill option is disabled.
Manage Line (Edit, Move, Resize, Delete)
Edit Line
Edit Line Appearance (UI)
- Select a line to view resize handles.
- Drag endpoints to adjust length/angle.
- Edit stroke color, opacity, and thickness using the annotation toolbar.

Use the annotation toolbar:
-
Edit Color tool

-
Edit Opacity slider

-
Line Properties
Open the Line Properties dialog via Right Click → Properties.

Edit Line Programmatically
Modify an existing Line programmatically using editAnnotation().
editLineProgrammatically(): void {
const pdfViewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
for (const annot of pdfViewer.annotationCollection) {
if (annot.subject === 'Line') {
annot.strokeColor = '#ff0000';
annot.thickness = 3;
pdfViewer.annotation.editAnnotation(annot);
break;
}
}
}Delete Line
The PDF Viewer supports deleting existing annotations through the UI and API.
See Delete Annotation for full behavior and workflows.
Comments
Use the Comments panel to add, view, and reply to threaded discussions linked to line annotations. It provides a dedicated interface for collaboration and review within the PDF Viewer.
Set properties while adding Individual Annotation
Set properties for individual line annotations using the lineSettings API or by passing per‑annotation values during addAnnotation.
addMultipleLines(): void {
const pdfViewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
// Line 1
pdfViewer.annotation.addAnnotation('Line', {
offset: { x: 200, y: 230 },
pageNumber: 1,
vertexPoints: [
{ x: 200, y: 230 },
{ x: 350, y: 230 }
],
strokeColor: '#0066ff',
thickness: 2,
opacity: 0.9,
author: 'User 1'
});
// Line 2
pdfViewer.annotation.addAnnotation('Line', {
offset: { x: 220, y: 300 },
pageNumber: 1,
vertexPoints: [
{ x: 220, y: 300 },
{ x: 400, y: 300 }
],
strokeColor: '#ff1010',
thickness: 3,
opacity: 0.9,
author: 'User 2'
});
}Disable Line Annotation
Disable shape annotations (Line, Arrow, Rectangle, Circle, Polygon) using the enableShapeAnnotation property.
import { Component } from '@angular/core';
import {
PdfViewerModule,
ToolbarService,
AnnotationService
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<ejs-pdfviewer
id="pdfViewer"
[enableShapeAnnotation]="false"
[documentPath]="document"
[resourceUrl]="resource"
style="height:650px;display:block">
</ejs-pdfviewer>
</div>
`,
imports: [PdfViewerModule],
providers: [ToolbarService, AnnotationService]
})
export class AppComponent {
public document: string =
'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string =
'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib';
}Handle Line Events
The PDF viewer provides annotation life-cycle events that notify when Line annotations are added, modified, selected, or removed.
For the full list of available events and their descriptions, see Annotation Events
Export and Import
The PDF Viewer supports exporting and importing annotations. For details on supported formats and workflows, see Export and Import annotations.