Skip to content

Commit ca4a665

Browse files
committed
994201-dev: Added EJ2 PDF library UG documentation.
1 parent 50d0bdd commit ca4a665

21 files changed

+8295
-7
lines changed

Document-Processing-toc.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,17 +2523,17 @@
25232523
</ul>
25242524
</li>
25252525
<li>
2526-
<a href="/document-processing/pdf/pdf-library/flutter/overview">Flutter</a>
2526+
<a href="/document-processing/pdf/pdf-library/javascript/Overview">JavaScript</a>
25272527
<ul>
2528-
#ReplaceUsingAutomation-https://github.com/syncfusion-content/flutter-docs/tree/master/Flutter/pdf#
2528+
<li><a href="/document-processing/pdf/pdf-library/javascript/Overview">Overview</a></li>
25292529
</ul>
25302530
</li>
25312531
<li>
2532-
<a href="/document-processing/pdf/pdf-library/javascript-es6/Overview">JavaScript (ES6)</a>
2532+
<a href="/document-processing/pdf/pdf-library/flutter/overview">Flutter</a>
25332533
<ul>
2534-
<li><a href="/document-processing/pdf/pdf-library/javascript-es6/Overview">Overview</a></li>
2534+
#ReplaceUsingAutomation-https://github.com/syncfusion-content/flutter-docs/tree/master/Flutter/pdf#
25352535
</ul>
2536-
</li>
2536+
</li>
25372537
</ul>
25382538
</li>
25392539
<li>
39.1 KB
Loading
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: post
3+
title: Getting started with JavaScript PDF library | Syncfusion
4+
description: Learn how to set up and use the Syncfusion JavaScript PDF library using the EJ2 quickstart, including local resource configuration and module injection.
5+
platform: document-processing
6+
control: PDF
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Getting started with JavaScript PDF library
12+
13+
This guide explains how to create the PDF library component and configure its features in TypeScript using the Essential JS 2 [quickstart](https://github.com/SyncfusionExamples/ej2-quickstart-webpack-) seed repository.
14+
15+
> This application is integrated with a webpack configuration (`webpack.config.js`) and uses the latest version of the [webpack-cli](https://webpack.js.org/api/cli/#commands). It requires Node.js `v14.15.0` or higher. For more information, refer to the [webpack getting started guide](https://webpack.js.org/guides/getting-started/).
16+
17+
## Dependencies
18+
19+
The following list of dependencies are required to use the `EJ2 PDF library` component in your application.
20+
21+
```javascript
22+
|-- @syncfusion/ej2-compression
23+
|-- @syncfusion/ej2-base
24+
|-- @syncfusion/ej2-file-utils
25+
26+
```
27+
28+
## Add Syncfusion JavaScript packages
29+
30+
Syncfusion JavaScript (Essential JS 2) packages are available on the [npmjs.com](https://www.npmjs.com/~syncfusionorg) public registry. Install all EJ2 controls with the [@syncfusion/ej2](https://www.npmjs.com/package/@syncfusion/ej2) meta package or install individual control packages.
31+
32+
The quickstart application is preconfigured with [@syncfusion/ej2](https://www.npmjs.com/package/@syncfusion/ej2) in `~/package.json`. Use the following command to install dependencies:
33+
34+
{% tabs %}
35+
{% highlight bash tabtitle="NPM" %}
36+
37+
npm install
38+
39+
{% endhighlight %}
40+
{% endtabs %}
41+
42+
## Create EJ2 PDF with local resources
43+
44+
This example demonstrates how to create a PDF document directly using Syncfusion EJ2 PDF library. A button is provided to trigger the PDF creation process.
45+
46+
{% tabs %}
47+
{% highlight ts tabtitle="index.ts" %}
48+
49+
// Create and render button
50+
let button: Button = new Button();
51+
button.appendTo('#normalbtn');
52+
53+
// Handle click event
54+
button.element.onclick = async () => {
55+
console.log('Start PDF Creation');
56+
createPdf();
57+
};
58+
59+
// Function to create PDF
60+
function createPdf() {
61+
// Create a new PDF document
62+
let document: PdfDocument = new PdfDocument();
63+
// Add a page
64+
const page = document.addPage();
65+
// Get graphics from the page
66+
let graphics = page.graphics;
67+
// Set font
68+
font: PdfStandardFont = new PdfStandardFont(PdfFontFamily.helvetica, 10);
69+
// Draw text
70+
graphics.drawString('Hello World!!!', font, [70, 10, 200, 50], new PdfPen([255, 0, 0], 1), new PdfBrush([0, 0, 255]));
71+
// Save the document
72+
document.save('Output.pdf');
73+
// Close the document
74+
document.destroy();
75+
}
76+
77+
{% endhighlight %}
78+
{% highlight html tabtitle="index.html" %}
79+
80+
<div class="row">
81+
<button id="normalbtn">Create PDF</button>
82+
</div>
83+
84+
{% endhighlight %}
85+
{% endtabs %}
86+
87+
By executing the program, you will get the PDF document as follows.
88+
89+
![Output EJ2 PDF document](EJ2-images/Helloworld.png)
90+
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
layout: post
3+
title: Open and save PDF files in JavaScript PDF library | Syncfusion
4+
description: Learn to load and save PDFs in Syncfusion JavaScript PDF library using URLs, base64 strings, or byte arrays with server-backed services.
5+
platform: document-processing
6+
control: PDF
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Open and save PDF files in JavaScript PDF library
12+
13+
## Opening an existing PDF document
14+
15+
Open an existing PDF document using the `PdfDocument` class with the specified string data.
16+
17+
```javascript
18+
// Load an existing PDF document from string data
19+
let document: PdfDocument = new PdfDocument("Input.pdf");
20+
21+
```
22+
23+
## Opening an existing PDF document from a byte array
24+
25+
Open an existing PDF document using the `PdfDocument` class with the specified byte array.
26+
27+
```javascript
28+
// Load the PDF data from a file
29+
const inputPDFByteArray: Uint8Array = new Uint8Array(fs.readFileSync('Input.pdf'));
30+
// Create a new PdfDocument instance using the byte array
31+
const loadedDocument = new PdfDocument(inputPDFByteArray);
32+
```
33+
34+
## Opening an Encrypted PDF document
35+
36+
Open an encrypted PDF document using the `PdfDocument` class by providing the correct password.
37+
38+
```javascript
39+
// Load an existing PDF document from string data
40+
let document: PdfDocument = new PdfDocument("Input.pdf", "password");
41+
```
42+
43+
## Opening an Encrypted PDF document from a byte array
44+
45+
Open an encrypted PDF document from a byte array using the `PdfDocument` class by providing the correct password.
46+
47+
```javascript
48+
// Load the PDF data from a file
49+
const inputPDFByteArray: Uint8Array = new Uint8Array(fs.readFileSync('Input.pdf'));
50+
// Load an existing PDF document from string data
51+
let document: PdfDocument = new PdfDocument(inputPDFByteArray, "password");
52+
```
53+
54+
## Saving a PDF document
55+
56+
Save the manipulated PDF document using the `Save` method of `PdfDocument` class with the specified string data.
57+
58+
```javascript
59+
// Load an existing PDF document from string data
60+
let document: PdfDocument = new PdfDocument("Input.pdf");
61+
//To-Do some manipulation
62+
//To-Do some manipulation
63+
// Save the PDF document
64+
document.save('Output.pdf');
65+
```
66+
67+
## Saving a PDF Document from a byte array
68+
69+
Open an existing PDF document using the `PdfDocument` class with the specified byte array.
70+
71+
```javascript
72+
// Load the PDF data from a file
73+
const inputPDFByteArray: Uint8Array = new Uint8Array(fs.readFileSync('Input.pdf'));
74+
// Create a new PdfDocument instance using the byte array
75+
const loadedDocument = new PdfDocument(inputPDFByteArray);
76+
//To-Do some manipulation
77+
//To-Do some manipulation
78+
// Save the document
79+
let data: Uint8Array = document.save();
80+
```
81+
82+
## Closing a document
83+
84+
After the document manipulation and save operation are completed, you should close the instance of `PdfDocument`, in order to release all the memory consumed by PDF DOM. The following code example illustrates how to destroy a `PdfDocument` instance.
85+
86+
```javascript
87+
// Load an existing PDF document from string data
88+
let document: PdfDocument = new PdfDocument("Input.pdf");
89+
//To-Do some manipulation
90+
//To-Do some manipulation
91+
// Save the PDF document
92+
document.save('Output.pdf');
93+
// Destroy the document
94+
document.destroy();
95+
```

Document-Processing/PDF/PDF-Library/javascript-es6/Overview.md renamed to Document-Processing/PDF/PDF-Library/javascript/Overview.md

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

1111
# Overview of the TypeScript PDF library control
1212

13-
The Essential<sup>&reg;</sup> TypeScript PDF library is a feature-rich, high-performance, non-UI PDF library written natively in TypeScript. It enables you to seamlessly integrate robust PDF functionalities into your TypeScript applications. The library allows users to read and manipulate PDF documents without requiring Adobe Acrobat.
13+
The Essential<sup>&reg;</sup> TypeScript PDF Library is a powerful, high-performance, non-UI solution built natively in TypeScript. It provides seamless integration of advanced PDF functionalities into applications developed with TypeScript, JavaScript, Angular, React, Vue, ASP.NET Core, and ASP.NET MVC. With this library, you can easily read, create, and manipulate PDF documentswithout relying on Adobe Acrobat.
1414

1515
## Key features
1616

@@ -32,4 +32,14 @@ The following are the key features of this library.
3232
* Digitally sign PDF documents for secure authentication.
3333
* Extract or redact text from PDF files.
3434
* Extract images from PDF documents.
35-
* Redact shapes to protect sensitive graphical content.
35+
* Redact shapes to protect sensitive graphical content.
36+
37+
## Supported web platforms
38+
39+
* ASP.Net core
40+
* ASP.Net MVC
41+
* Angular
42+
* React
43+
* Vue
44+
* JavaScript
45+
* TypeScript

0 commit comments

Comments
 (0)