Skip to content

Commit bfe3477

Browse files
Merge pull request #1877 from syncfusion-content/995120-extractPagePlatformWise
995120: Extract pages UG Documentation PDF Viewer
2 parents 037bfe3 + 5a36352 commit bfe3477

31 files changed

+1035
-0
lines changed

Document-Processing-toc.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-core/organize-pages/programmatic-support">Programmatic Support for Organize Page</a></li>
203203
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-core/organize-pages/ui-interactions">UI Interactions in Organize Page</a></li>
204204
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-core/organize-pages/toolbar">Toolbar</a></li>
205+
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-core/organize-pages/extract-pages">Extract Pages</a></li>
205206
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-core/organize-pages/mobile-view">Organize Page in Mobile View</a></li>
206207
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-core/organize-pages/events">Events in Organize Page</a></li>
207208
</ul>
@@ -377,6 +378,7 @@
377378
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-mvc/organize-pages/programmatic-support">Programmatic Support</a></li>
378379
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-mvc/organize-pages/ui-interactions">UI Interactions</a></li>
379380
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-mvc/organize-pages/toolbar">Toolbar</a></li>
381+
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-mvc/organize-pages/extract-pages">Extract Pages</a></li>
380382
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-mvc/organize-pages/mobile-view">Mobile View</a></li>
381383
<li><a href="/document-processing/pdf/pdf-viewer/asp-net-mvc/organize-pages/events">Events</a></li>
382384
</ul>
@@ -562,6 +564,7 @@
562564
<li><a href="/document-processing/pdf/pdf-viewer/angular/organize-pages/programmatic-support">Programmatic Support</a></li>
563565
<li><a href="/document-processing/pdf/pdf-viewer/angular/organize-pages/ui-interactions">UI Interactions</a></li>
564566
<li><a href="/document-processing/pdf/pdf-viewer/angular/organize-pages/toolbar">Toolbar</a></li>
567+
<li><a href="/document-processing/pdf/pdf-viewer/angular/organize-pages/extract-pages">Extract Pages</a></li>
565568
<li><a href="/document-processing/pdf/pdf-viewer/angular/organize-pages/mobile-view">Mobile View</a></li>
566569
<li><a href="/document-processing/pdf/pdf-viewer/angular/organize-pages/events">Events</a></li>
567570
</ul>
@@ -897,6 +900,7 @@
897900
<li><a href="/document-processing/pdf/pdf-viewer/react/organize-pages/programmatic-support">Programmatic Support</a></li>
898901
<li><a href="/document-processing/pdf/pdf-viewer/react/organize-pages/ui-interactions">UI Interactions</a></li>
899902
<li><a href="/document-processing/pdf/pdf-viewer/react/organize-pages/toolbar">Toolbar</a></li>
903+
<li><a href="/document-processing/pdf/pdf-viewer/react/organize-pages/extract-pages">Extract Pages</a></li>
900904
<li><a href="/document-processing/pdf/pdf-viewer/react/organize-pages/mobile-view">Mobile View</a></li>
901905
<li><a href="/document-processing/pdf/pdf-viewer/react/organize-pages/events">Events</a></li>
902906
</ul>
@@ -1068,6 +1072,7 @@
10681072
<li><a href="/document-processing/pdf/pdf-viewer/vue/organize-pages/programmatic-support">Programmatic Support</a></li>
10691073
<li><a href="/document-processing/pdf/pdf-viewer/vue/organize-pages/ui-interactions">UI Interactions</a></li>
10701074
<li><a href="/document-processing/pdf/pdf-viewer/vue/organize-pages/toolbar">Toolbar</a></li>
1075+
<li><a href="/document-processing/pdf/pdf-viewer/vue/organize-pages/extract-pages">Extract Pages</a></li>
10711076
<li><a href="/document-processing/pdf/pdf-viewer/vue/organize-pages/mobile-view">Mobile View</a></li>
10721077
<li><a href="/document-processing/pdf/pdf-viewer/vue/organize-pages/events">Events</a></li>
10731078
</ul>
@@ -1242,6 +1247,7 @@
12421247
<li><a href="/document-processing/pdf/pdf-viewer/javascript-es5/organize-pages/programmatic-support">Programmatic Support</a></li>
12431248
<li><a href="/document-processing/pdf/pdf-viewer/javascript-es5/organize-pages/ui-interactions">UI Interactions</a></li>
12441249
<li><a href="/document-processing/pdf/pdf-viewer/javascript-es5/organize-pages/toolbar">Toolbar</a></li>
1250+
<li><a href="/document-processing/pdf/pdf-viewer/javascript-es5/organize-pages/extract-pages">Extract Pages</a></li>
12451251
<li><a href="/document-processing/pdf/pdf-viewer/javascript-es5/organize-pages/mobile-view">Mobile View</a></li>
12461252
<li><a href="/document-processing/pdf/pdf-viewer/javascript-es5/organize-pages/events">Events</a></li>
12471253
</ul>
53.6 KB
Loading
55.9 KB
Loading
43.8 KB
Loading
49.3 KB
Loading
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
---
2+
layout: post
3+
title: Extract Pages in Angular PDF Viewer | Syncfusion
4+
description: Learn here all about Extract Pages in Organize Pages in Syncfusion Angular PDF Viewer component of Syncfusion Essential JS 2 and more.
5+
platform: document-processing
6+
control: PDF Viewer
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Extract pages in Angular PDF Viewer
12+
13+
The PDF Viewer component lets you extract pages from a document using the Extract Pages option in the Organize Pages UI, and also control extraction programmatically. The Extract Pages tool is available by default in Organize Pages.
14+
15+
## Extract Pages in Organize Pages
16+
17+
- Open the Organize Pages panel in the PDF Viewer toolbar.
18+
- Locate and click the Extract Pages option.
19+
20+
![Extract Pages](../images/extract-page.png)
21+
22+
When selected, a secondary toolbar dedicated to extraction is displayed.
23+
24+
![Extract Pages secondary toolbar](../images/extract-page-secondary-toolbar.png)
25+
26+
## Extract pages using the UI
27+
28+
You can extract by typing page numbers/ranges or by selecting thumbnails.
29+
30+
1. Click Extract Pages in the Organize Pages panel.
31+
2. In the input box, enter the pages to extract. Supported formats include:
32+
- Single pages: 1,3,5
33+
- Ranges: 2-6
34+
- Combinations: 1,4,7-9
35+
3. Alternatively, select the page thumbnails you want instead of typing values.
36+
4. Click Extract to download the extracted pages as a new PDF. Click Cancel to close the tool.
37+
38+
![Extract Pages with selected thumbnails](../images/extract-page-selected-thumbnail.png)
39+
40+
N> Page numbers are 1-based (first page is 1). Invalid or out-of-range entries are ignored.
41+
42+
## Extraction options (checkboxes)
43+
44+
Two options appear in the secondary toolbar:
45+
46+
- **Delete Pages After Extracting:**
47+
- 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.
48+
49+
- **Extract Pages As Separate Files:**
50+
- 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.
51+
52+
![Checkboxes for extract options](../images/extract-page-checkboxes.png)
53+
54+
## Programmatic options and APIs
55+
56+
### Enable/disable or show/hide Extract Pages
57+
58+
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`.
59+
60+
Use the following code snippet to enable or disable the Extract Pages option:
61+
62+
{% tabs %}
63+
{% highlight ts tabtitle="Standalone" %}
64+
import { Component, OnInit } from '@angular/core';
65+
import {
66+
LinkAnnotationService,
67+
BookmarkViewService,
68+
MagnificationService,
69+
ThumbnailViewService,
70+
ToolbarService,
71+
NavigationService,
72+
AnnotationService,
73+
TextSearchService,
74+
TextSelectionService,
75+
FormFieldsService,
76+
FormDesignerService,
77+
PrintService,
78+
PageOrganizerService,
79+
} from '@syncfusion/ej2-angular-pdfviewer';
80+
81+
@Component({
82+
selector: 'app-root',
83+
template: `
84+
<div class="content-wrapper">
85+
<ejs-pdfviewer
86+
id="pdfViewer"
87+
[resourceUrl]="resourceUrl"
88+
[documentPath]="document"
89+
[pageOrganizerSettings]= {canExtractPages: false}
90+
style="height: 640px; display: block;">
91+
</ejs-pdfviewer>
92+
</div>
93+
`,
94+
providers: [
95+
LinkAnnotationService,
96+
BookmarkViewService,
97+
MagnificationService,
98+
ThumbnailViewService,
99+
ToolbarService,
100+
NavigationService,
101+
AnnotationService,
102+
TextSearchService,
103+
TextSelectionService,
104+
FormFieldsService,
105+
FormDesignerService,
106+
PrintService,
107+
PageOrganizerService,
108+
]
109+
})
110+
export class AppComponent implements OnInit {
111+
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
112+
public resourceUrl: string = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
113+
ngOnInit(): void { }
114+
}
115+
{% endhighlight %}
116+
{% endtabs %}
117+
118+
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`.
119+
120+
Use the following code snippet to remove the Extract Pages option:
121+
122+
{% tabs %}
123+
{% highlight ts tabtitle="Standalone" %}
124+
import { Component, OnInit } from '@angular/core';
125+
import {
126+
LinkAnnotationService,
127+
BookmarkViewService,
128+
MagnificationService,
129+
ThumbnailViewService,
130+
ToolbarService,
131+
NavigationService,
132+
AnnotationService,
133+
TextSearchService,
134+
TextSelectionService,
135+
FormFieldsService,
136+
FormDesignerService,
137+
PrintService,
138+
PageOrganizerService,
139+
} from '@syncfusion/ej2-angular-pdfviewer';
140+
141+
@Component({
142+
selector: 'app-root',
143+
template: `
144+
<div class="content-wrapper">
145+
<ejs-pdfviewer
146+
id="pdfViewer"
147+
[resourceUrl]="resourceUrl"
148+
[documentPath]="document"
149+
[pageOrganizerSettings]={showExtractPagesOption: false}
150+
style="height: 640px; display: block;">
151+
</ejs-pdfviewer>
152+
</div>
153+
`,
154+
providers: [
155+
LinkAnnotationService,
156+
BookmarkViewService,
157+
MagnificationService,
158+
ThumbnailViewService,
159+
ToolbarService,
160+
NavigationService,
161+
AnnotationService,
162+
TextSearchService,
163+
TextSelectionService,
164+
FormFieldsService,
165+
FormDesignerService,
166+
PrintService,
167+
PageOrganizerService,
168+
]
169+
})
170+
export class AppComponent implements OnInit {
171+
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
172+
public resourceUrl: string = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
173+
ngOnInit(): void { }
174+
}
175+
{% endhighlight %}
176+
{% endtabs %}
177+
178+
### Extract pages and load the result programmatically
179+
180+
You can extract pages programmatically using the `extractPages` method.
181+
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.
182+
183+
{% tabs %}
184+
{% highlight ts tabtitle="Standalone" %}
185+
import { Component, OnInit } from '@angular/core';
186+
import {
187+
LinkAnnotationService,
188+
BookmarkViewService,
189+
MagnificationService,
190+
ThumbnailViewService,
191+
ToolbarService,
192+
NavigationService,
193+
AnnotationService,
194+
TextSearchService,
195+
TextSelectionService,
196+
FormFieldsService,
197+
FormDesignerService,
198+
PrintService,
199+
PageOrganizerService,
200+
} from '@syncfusion/ej2-angular-pdfviewer';
201+
202+
@Component({
203+
selector: 'app-root',
204+
template: `
205+
<div class="content-wrapper">
206+
<button (click)="onExtract()">Extract Pages</button>
207+
<ejs-pdfviewer
208+
id="pdfViewer"
209+
[resourceUrl]="resourceUrl"
210+
[documentPath]="document"
211+
[pageOrganizerSettings]={showExtractPagesOption:true}
212+
style="height: 640px; display: block;">
213+
</ejs-pdfviewer>
214+
</div>
215+
`,
216+
providers: [
217+
LinkAnnotationService,
218+
BookmarkViewService,
219+
MagnificationService,
220+
ThumbnailViewService,
221+
ToolbarService,
222+
NavigationService,
223+
AnnotationService,
224+
TextSearchService,
225+
TextSelectionService,
226+
FormFieldsService,
227+
FormDesignerService,
228+
PrintService,
229+
PageOrganizerService,
230+
]
231+
})
232+
export class AppComponent implements OnInit {
233+
public document: string = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
234+
public resourceUrl: string = 'https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib';
235+
ngOnInit(): void { }
236+
237+
238+
onExtract() {
239+
const viewer = (document.getElementById('pdfViewer') as any).ej2_instances[0];
240+
// Extract pages 1 and 2
241+
const array = (viewer as any).extractPages('1,2');
242+
// Load the extracted pages back into the viewer
243+
(viewer as any).load(array,"");
244+
console.log(array);
245+
}
246+
}
247+
{% endhighlight %}
248+
{% endtabs %}
249+
250+
[View sample in GitHub](https://github.com/SyncfusionExamples/angular-pdf-viewer-examples/tree/master/How%20to)
251+
252+
## See also
253+
254+
- [Overview](../overview)
255+
- [UI interactions](../ui-interactions)
256+
- [Programmatic support](../programmatic-support)
257+
- [Toolbar](../toolbar)
258+
- [Events](../events)
259+
- [Mobile view](../mobile-view)
53.6 KB
Loading
55.9 KB
Loading
43.8 KB
Loading
49.3 KB
Loading

0 commit comments

Comments
 (0)