How can I help you?
Extract pages in Angular PDF Viewer
11 Feb 20268 minutes to read
The PDF Viewer component enables users to extract pages from a document using the Extract Pages option in the Organize Pages UI and to control extraction programmatically. The Extract Pages tool is available by default in Organize Pages.
Extract Pages in Organize Pages
- Open the Organize Pages panel in the PDF Viewer toolbar.
- Locate and click the Extract Pages option.

When selected, a secondary toolbar dedicated to extraction is displayed.

Extract pages using the UI
You can extract by typing page numbers/ranges or by selecting thumbnails.
- Click Extract Pages in the Organize Pages panel.
- In the input box, enter the pages to extract. Supported formats include:
- Single pages: 1,3,5
- Ranges: 2-6
- Combinations: 1,4,7-9
- Alternatively, select the page thumbnails you want instead of typing values.
- Click Extract to download the extracted pages as a new PDF. Click Cancel to close the tool.
![]()
Note: Page numbers are 1-based (first page is 1). Invalid or out-of-range entries are ignored.
Extraction options (checkboxes)
Two options appear in the secondary toolbar:
-
Delete Pages After Extracting:
- When enabled, the selected/entered pages are removed from the document opened in the viewer after the extraction completes. The extracted pages are still downloaded as a new file.
-
Extract Pages As Separate Files:
- When enabled, every selected page is exported as an individual PDF file. Ranges such as 2-4 export pages 2, 3, and 4 as separate PDFs.

Programmatic options and APIs
Enable/disable or show/hide Extract Pages
Use the canExtractPages API to enable or disable the Extract Pages option. When set to false, the Extract Pages tool is disabled in the toolbar. The default value is true.
Use the following code snippet to enable or disable the Extract Pages option:
import { Component, OnInit } from '@angular/core';
import {
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService,
PageOrganizerService,
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<ejs-pdfviewer
id="pdfViewer"
[resourceUrl]="resourceUrl"
[documentPath]="document"
[pageOrganizerSettings]= {canExtractPages: false}
style="height: 640px; display: block;">
</ejs-pdfviewer>
</div>
`,
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService,
PageOrganizerService,
]
})
export class AppComponent implements OnInit {
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resourceUrl: string = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
ngOnInit(): void { }
}Use the showExtractPagesOption API to show or hide the Extract Pages option. When set to false, the Extract Pages tool is removed from the toolbar. The default value is true.
Use the following code snippet to remove the Extract Pages option:
import { Component, OnInit } from '@angular/core';
import {
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService,
PageOrganizerService,
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<ejs-pdfviewer
id="pdfViewer"
[resourceUrl]="resourceUrl"
[documentPath]="document"
[pageOrganizerSettings]={showExtractPagesOption: false}
style="height: 640px; display: block;">
</ejs-pdfviewer>
</div>
`,
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService,
PageOrganizerService,
]
})
export class AppComponent implements OnInit {
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resourceUrl: string = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
ngOnInit(): void { }
}Extract pages and load the result programmatically
You can extract pages programmatically using the extractPages method.
The following example extracts pages 1 and 2, then immediately loads the extracted pages back into the viewer. The returned value is a byte array (e.g., Uint8Array) representing the PDF file contents.
import { Component, OnInit } from '@angular/core';
import {
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService,
PageOrganizerService,
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
template: `
<div class="content-wrapper">
<button (click)="onExtract()">Extract Pages</button>
<ejs-pdfviewer
id="pdfViewer"
[resourceUrl]="resourceUrl"
[documentPath]="document"
[pageOrganizerSettings]={showExtractPagesOption:true}
style="height: 640px; display: block;">
</ejs-pdfviewer>
</div>
`,
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
AnnotationService,
TextSearchService,
TextSelectionService,
FormFieldsService,
FormDesignerService,
PrintService,
PageOrganizerService,
]
})
export class AppComponent implements OnInit {
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resourceUrl: string = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
ngOnInit(): void { }
onExtract() {
const viewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
// Extract pages 1 and 2
const array = (viewer as any).extractPages('1,2');
// Load the extracted pages back into the viewer
(viewer as any).load(array,"");
console.log(array);
}
}