Skip to content

Commit 046c610

Browse files
988524: Getting started and Getting started server-backend Revamp
1 parent 6117173 commit 046c610

File tree

2 files changed

+92
-48
lines changed

2 files changed

+92
-48
lines changed

Document-Processing/PDF/PDF-Viewer/angular/getting-started-with-server-backed.md

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
22
layout: post
3-
title: Getting started with Angular PDF Viewer component | Syncfusion
4-
description: Checkout and learn about Getting started with Angular PDF Viewer component of Syncfusion Essential JS 2 and more details.
3+
title: Getting started with Angular PDF Viewer (server-backed) | Syncfusion
4+
description: Learn how to set up and use the Syncfusion Angular PDF Viewer in server-backed mode, including module injection and web service configuration.
55
platform: document-processing
66
control: PDF Viewer
77
documentation: ug
88
domainurl: ##DomainURL##
99
---
1010

11-
# Getting started with PDF Viewer component
11+
# Getting started with Angular PDF Viewer (server-backed)
1212

13-
This section explains the steps required to create a simple Angular PDF Viewer and demonstrates the basic usage of the PDF Viewer control in a Angular CLI application.
13+
This guide explains how to create the PDF Viewer component and configure its features in Angular using the Essential JS 2 in server-backed mode.
1414

15-
## Setup Angular Environment
15+
## Set up the development environment
1616

1717
You can use the [`Angular CLI`](https://github.com/angular/angular-cli) to setup your Angular applications.
1818
To install the latest Angular CLI globally use the following command.
@@ -21,9 +21,7 @@ To install the latest Angular CLI globally use the following command.
2121
npm install -g @angular/cli
2222
```
2323

24-
N> Use the command **npm install --save @angular/cli@12.0.2** to install the Angular CLI version 12.0.2
25-
26-
## Create an Angular Application
24+
## Create an Angular application
2725

2826
Start a new Angular application using the Angular CLI command as follows.
2927

@@ -32,15 +30,31 @@ ng new my-app
3230
cd my-app
3331
```
3432

35-
## Installing Syncfusion<sup style="font-size:70%">&reg;</sup> PDF Viewer package
33+
## Add Syncfusion JavaScript packages
3634

37-
All the available Essential<sup style="font-size:70%">&reg;</sup> JS 2 packages are published in `npmjs.com` registry. To install PDF Viewer component, use the following command.
35+
All the available Essential JS 2 packages are published in the [npmjs.com](https://www.npmjs.com/~syncfusionorg) public registry. To install PDF Viewer component, use the following command.
3836

3937
```bash
4038
npm install @syncfusion/ej2-angular-pdfviewer --save
4139
```
4240

43-
## Registering PDF Viewer Module
41+
## Import Syncfusion CSS styles
42+
43+
Add the component CSS in the `~/src/styles.css` file, as shown below:
44+
45+
```css
46+
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
47+
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
48+
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
49+
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
50+
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
51+
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
52+
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
53+
@import '../node_modules/@syncfusion/ej2-pdfviewer/styles/material.css';
54+
@import '../node_modules/@syncfusion/ej2-notifications/styles/material.css';
55+
```
56+
57+
## Add the PDF Viewer component
4458

4559
Import PDF Viewer module into Angular application(app.module.ts) from the package `@syncfusion/ej2-angular-pdfviewer` [src/app/app.module.ts].
4660

@@ -68,24 +82,6 @@ import { AppComponent } from './app.component';
6882
export class AppModule { }
6983
```
7084

71-
## Adding CSS reference
72-
73-
Add the Angular PDF Viewer component’s styles as given below in `src/styles.css` file.
74-
75-
```css
76-
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
77-
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
78-
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
79-
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
80-
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
81-
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
82-
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
83-
@import '../node_modules/@syncfusion/ej2-pdfviewer/styles/material.css';
84-
@import '../node_modules/@syncfusion/ej2-notifications/styles/material.css';
85-
```
86-
87-
## Adding PDF Viewer component
88-
8985
Add the Angular PDF Viewer by using `<ejs-pdfviewer>` selector in `template` section of the `src/app/app.component.ts` file to render the PDF Viewer component.
9086

9187
```typescript
@@ -118,7 +114,7 @@ export class AppComponent implements OnInit {
118114
}
119115
}
120116
```
121-
N> The Web API hosted link https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer utilized in the PDF viewer's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-PDFViewer-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/pdfviewer-server) for hosting your own web service and use for the serviceUrl property. **We strongly recommend using the standalone mode.**
117+
N> The Web API link https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/ used in the `serviceUrl` property is intended for demonstration and evaluation only. For production, host your own web service with the required server configuration. You can reuse the [GitHub web service example](https://github.com/SyncfusionExamples/EJ2-PDFViewer-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/pdfviewer-server). **Standalone mode is strongly recommended.**
122118

123119
## Run the application
124120

@@ -158,30 +154,52 @@ platformBrowserDynamic().bootstrapModule(AppModule)
158154

159155
> For PDF Viewer serviceUrl creation, follow the steps provided in the [link](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/javascript-es6/how-to/create-pdfviewer-service)
160156
161-
## How to run the PDF Viewer web service
157+
## Module injection
158+
159+
To enable additional features, inject the required modules. The following modules extend the PDF Viewer's functionality:
160+
161+
* `LinkAnnotationService`: Enables hyperlink navigation.
162+
* `BookmarkViewService`: Displays and navigates document bookmarks.
163+
* `MagnificationService`: Provides zoom in/out operations.
164+
* `NavigationService`: Enables page navigation.
165+
* `TextSelectionService`: Enables text selection.
166+
* `ThumbnailViewService`: Displays page thumbnails for navigation.
167+
* `ToolbarService`: Enables the built-in toolbar UI.
168+
* `PrintService`: Enables printing.
169+
* `AnnotationService`: Enables annotation features.
170+
* `TextSearchService`: Enables text search.
171+
* `FormFieldsService`: Enables form field support.
172+
* `FormDesignerService`: Enables designing and editing of form fields.
173+
* `PageOrganizerService`: Enables page organization features.
174+
175+
Inject modules using the `providers` property in `@NgModule`.
162176

163-
1. Download the sample from the [Web service sample in GitHub](https://github.com/SyncfusionExamples/EJ2-PDFViewer-WebServices) link.
177+
> To create a PDF Viewer `serviceUrl`, follow the steps in [Create PDF Viewer service](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/javascript-es6/how-to/create-pdfviewer-service).
164178
165-
2. Navigate to the `ASP.NET Core` folder and open it in the command prompt.
179+
## Run the PDF Viewer web service
180+
181+
1. Download the sample from the [web service sample in GitHub](https://github.com/SyncfusionExamples/EJ2-PDFViewer-WebServices).
182+
183+
2. Navigate to the `ASP.NET Core` folder and open it in a command prompt.
166184

167185
3. Navigate to the appropriate subfolder based on your .NET version:
168186

169187
- .NET 6.0 → `PdfViewerWebService_6.0`
170188
- .NET 8.0 → `PdfViewerWebService_8.0`
171189

172-
4. Use the below command to restore the required packages.
190+
4. Restore packages:
173191

174-
```sh
175-
dotnet restore
176-
```
192+
```
193+
dotnet restore
194+
```
177195

178-
5. Use the below command to run the web service.
196+
5. Run the web service:
179197

180-
```sh
181-
dotnet run
182-
```
198+
```
199+
dotnet run
200+
```
183201

184-
6. You can see that the PDF Viewer server instance runs in the local host with the port number `localhost:5001`and navigate to the PDF Viewer Web control `localhost:5001/pdfviewer`which returns the default get response method. We can bind the link to the `serviceUrl` property of PDF Viewer as below.
202+
6. The PDF Viewer server instance runs at `https://localhost:5001`. Navigate to `https://localhost:5001/pdfviewer` to see the default GET response. Bind this URL to the `serviceUrl` property of the PDF Viewer as shown below.
185203

186204
```javascript
187205
export class AppComponent implements OnInit {
@@ -190,9 +208,12 @@ platformBrowserDynamic().bootstrapModule(AppModule)
190208
ngOnInit(): void {
191209
}
192210
```
193-
N> When configuring the server-backed PDF viewer, it's Essential<sup style="font-size:70%">&reg;</sup> to understand that there is no need to include the pdfium.js and pdfium.wasm files. Unlike the standalone PDF viewer, which relies on these files for local rendering, the server-backed PDF viewer fetches and renders PDFs directly from the server. Consequently, you can exclude the copy command for deployment process, as they are not required to load and display PDFs in this context.
194211
195-
N> For hosting the web service on the Linux platform, ensure to include the [SkiaSharp.NativeAssets.Linux](https://nuget.org/packages/SkiaSharp.NativeAssets.Linux/3.116.1). Additionally, for AWS environments, utilize the following packages:
212+
N> In server-backed mode, do not include `pdfium.js` and `pdfium.wasm`. Unlike standalone mode, the server-backed PDF Viewer renders PDFs on the server. These files and their copy steps are not required for deployment in this context.
213+
214+
> Refer to the [Angular PDF Viewer feature tour](https://www.syncfusion.com/pdf-viewer-sdk) for an overview of capabilities. Explore the [Angular PDF Viewer example](https://document.syncfusion.com/demos/pdf-viewer/angular/#/tailwind3/pdfviewer/default.html) to see core features in action.
215+
216+
N> For hosting the web service on Linux, include [SkiaSharp.NativeAssets.Linux](https://nuget.org/packages/SkiaSharp.NativeAssets.Linux/3.116.1). For AWS environments, use the following packages:
196217
197218
| **Amazon Web Services (AWS)** |**NuGet package name** |
198219
| --- | --- |

Document-Processing/PDF/PDF-Viewer/angular/getting-started.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ domainurl: ##DomainURL##
1010

1111
# Getting started with Standalone PDF Viewer component
1212

13-
This section explains the steps required to create a simple Standalone Angular PDF Viewer and demonstrates the basic usage of the PDF Viewer control in a Angular CLI application (for Angular versions below 17).
13+
This section explains the steps required to create a simple Standalone Angular PDF Viewer and demonstrates the basic usage of the PDF Viewer control in an Angular CLI application.
1414

1515
N> For Angular 17+, see the following links:
1616

@@ -87,7 +87,7 @@ export class AppModule { }
8787

8888
## Adding CSS reference
8989

90-
Add the Angular PDF Viewer components styles as given below in `src/styles.css` file.
90+
Add the Angular PDF Viewer component's styles as given below in `src/styles.css` file.
9191

9292
```css
9393
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@@ -101,7 +101,7 @@ Add the Angular PDF Viewer component’s styles as given below in `src/styles.cs
101101
@import '../node_modules/@syncfusion/ej2-notifications/styles/material.css';
102102
```
103103

104-
## Adding PDF Viewer component
104+
## Add the PDF Viewer component
105105

106106
Add the Angular PDF Viewer by using `<ejs-pdfviewer>` selector in `template` section of the `src/app/app.component.ts` file to render the PDF Viewer component.
107107

@@ -135,7 +135,8 @@ export class AppComponent implements OnInit {
135135
}
136136
}
137137
```
138-
### Steps to Load PDF Viewer with Local Resources
138+
139+
### Load PDF Viewer with local resources
139140

140141
To configure the PDF Viewer to use local files for `documentPath` and `resourceUrl` instead of files hosted on a CDN, follow these steps:
141142

@@ -216,4 +217,26 @@ platformBrowserDynamic().bootstrapModule(AppModule)
216217

217218
{% previewsample "Document-Processing/samples/pdfviewer/angular/getting-started-cs1-standalone/index.html" %}
218219

220+
## Module injection
221+
222+
To enable additional features, inject the required modules. The following modules extend the PDF Viewer's functionality:
223+
224+
* `LinkAnnotationService`: Enables hyperlink navigation.
225+
* `BookmarkViewService`: Displays and navigates document bookmarks.
226+
* `MagnificationService`: Provides zoom in/out operations.
227+
* `NavigationService`: Enables page navigation.
228+
* `TextSelectionService`: Enables text selection.
229+
* `ThumbnailViewService`: Displays page thumbnails for navigation.
230+
* `ToolbarService`: Enables the built-in toolbar UI.
231+
* `PrintService`: Enables printing.
232+
* `AnnotationService`: Enables annotation features.
233+
* `TextSearchService`: Enables text search.
234+
* `FormFieldsService`: Enables form field support.
235+
* `FormDesignerService`: Enables designing and editing of form fields.
236+
* `PageOrganizerService`: Enables page organization features.
237+
238+
Inject modules using the `providers` array in the component or module.
239+
240+
> Refer to the [Angular PDF Viewer feature tour](https://www.syncfusion.com/pdf-viewer-sdk/angular-pdf-viewer) for an overview of capabilities. Explore the [Angular PDF Viewer example](https://document.syncfusion.com/demos/pdf-viewer/angular/#/tailwind3/pdfviewer/default) to see core features in action.
241+
219242
[View sample in GitHub](https://github.com/SyncfusionExamples/angular-pdf-viewer-examples/tree/master/Getting%20started%20-%20Standalone).

0 commit comments

Comments
 (0)