Skip to content

Commit 375a3d0

Browse files
committed
999358-ug: Added proper code example and content.
1 parent 65e97b5 commit 375a3d0

8 files changed

Lines changed: 86 additions & 46 deletions

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-angular.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ All the available JS 2 packages are published in `npmjs.com` registry.
4444
npm install @syncfusion/ej2-pdf --save
4545
```
4646
N> For data extraction features, you need to install the `@syncfusion/ej2-pdf-data-extract` package as an add-on.
47+
* Copy the contents of the openjpeg folder from ./node_modules/@syncfusion/ej2-pdf-data-extract/dist to the public directory using the command:
48+
```bash
49+
cp -R ./node_modules/@syncfusion/ej2-pdf-data-extract/dist/openjpeg public/js/openjpeg
50+
```
51+
* Confirm that there is an 'openjpeg' directory within your public directory, if you extracting images from PDF.
52+
* Validate that your server has been configured to utilize the Content-Type: application/wasm MIME type.
4753

4854
## Create a PDF document using TypeScript
4955

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-asp-net-core.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ N> Check out the following topics for including script references in an ASP.NET
3939
* [CDN](https://ej2.syncfusion.com/aspnetcore/documentation/common/adding-script-references#cdn-reference)
4040
* [NPM Package](https://ej2.syncfusion.com/aspnetcore/documentation/common/adding-script-references#node-package-manager-npm)
4141
* [CRG](https://ej2.syncfusion.com/aspnetcore/documentation/common/custom-resource-generator)
42-
N> And ensure the application includes an `openjpeg` folder under `wwwroot` (or a publicly accessible static path). This folder must contain the `openjpeg.js` and `openjpeg.wasm` files, along with the PDF file to extract images. Keep these in the same static content area as `ej2.min.js`.
42+
And ensure the application includes an `openjpeg` folder under `wwwroot` (or a publicly accessible static path). This folder must contain the `openjpeg.js` and `openjpeg.wasm` files, along with the PDF file to extract images. Keep these in the same static content area as `ej2.min.js`.
4343

4444
Step 6: **Create a PDF document** : Add the script in `~/Views/Home/Index.cshtml` by creating a button and attaching a click event that uses the JavaScript PDF API to generate a PDF document.
4545

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-asp-net-mvc.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ Step 5: **Add script reference** : Add the required scripts using the CDN inside
3636
{% endhighlight %}
3737
{% endtabs %}
3838

39-
N> And ensure the application includes an `openjpeg` folder under `Scripts` (or a publicly accessible static path). This folder must contain the `openjpeg.js` and `openjpeg.wasm` files, along with the PDF file to extract images. Keep these in the same static content area as `ej2.min.js`.
39+
N> Check out the following topics for including script references in an ASP.NET MVC application to enable PDF creation using the Syncfusion<sup>&reg;</sup> JavaScript PDF library:
40+
* [CDN](https://ej2.syncfusion.com/aspnetmvc/documentation/common/adding-script-references)
41+
* [NPM Package](https://ej2.syncfusion.com/aspnetmvc/documentation/common/adding-script-references#node-package-manager-npm)
42+
* [CRG](https://ej2.syncfusion.com/aspnetmvc/documentation/common/custom-resource-generator)
43+
And ensure the application includes an `openjpeg` folder under `Scripts` (or a publicly accessible static path). This folder must contain the `openjpeg.js` and `openjpeg.wasm` files, along with the PDF file to extract images. Keep these in the same static content area as `ej2.min.js`.
4044

4145
Step 6: **Create a PDF document** : Add the script in `~/Views/Home/Index.cshtml` by creating a button and attaching a click event that uses the JavaScript PDF API to generate a PDF document.
4246

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-javascript.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ Step 3: Create a HTML page (index.html) in `my-app` location and add the CDN lin
3939
{% endhighlight %}
4040
{% endtabs %}
4141

42+
N> For the JavaScript platform, place the **openjpeg** folder in the same location as your `index.html` file. Ensure that your application includes an `openjpeg` folder under `Scripts` (or any publicly accessible static path). This folder must contain the following:
43+
* `openjpeg.js`
44+
* `openjpeg.wasm`
45+
Along with the PDF file from which you want to extract images. Keep these files in the same static content area as `ej2.min.js` to ensure proper loading.
46+
4247
Step 4: **Create a PDF document** : Add the script in `index.html` by creating a button and attaching a click event that uses the JavaScript PDF API to generate a PDF document.
4348

4449
{% tabs %}
@@ -73,12 +78,6 @@ Step 4: **Create a PDF document** : Add the script in `index.html` by creating a
7378
{% endhighlight %}
7479
{% endtabs %}
7580

76-
N> For the JavaScript platform, place the **openjpeg** folder in the same location as your `index.html` file. Ensure that your application includes an `openjpeg` folder under `Scripts` (or any publicly accessible static path). This folder must contain the following:
77-
* `openjpeg.js`
78-
* `openjpeg.wasm`
79-
80-
Along with the PDF file from which you want to extract images. Keep these files in the same static content area as `ej2.min.js` to ensure proper loading.
81-
8281
By executing the program, you will get the PDF document as follows.
8382

8483
![Output PDF document](Getting_started_images/Output.png)

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-react.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ All the available JS 2 packages are published in `npmjs.com` registry.
2424
npm install @syncfusion/ej2-pdf --save
2525
```
2626
N> For data extraction features, you need to install the `@syncfusion/ej2-pdf-data-extract` package as an add-on.
27-
2827
* Copy the contents of the openjpeg folder from ./node_modules/@syncfusion/ej2-pdf-data-extract/dist to the public directory using the command:
2928
```bash
3029
cp -R ./node_modules/@syncfusion/ej2-pdf-data-extract/dist/openjpeg public/openjpeg
3130
```
3231
* Confirm that there is an 'openjpeg' directory within your public directory, if you extracting images from PDF.
33-
* Validate that your server has been configured to utilize the Content-Type: application/wasm MIME type. Additional information can be found in the [Troubleshooting](./troubleshooting/troubleshooting) section.
32+
* Validate that your server has been configured to utilize the Content-Type: application/wasm MIME type.
3433

3534
**Create a PDF document** : Add the script in `App.jsx` by creating a button and attaching a click event that uses the JavaScript PDF API to generate a PDF document.
3635

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-typescript.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ The Syncfusion<sup>&reg;</sup> TypeScript PDF library is used to create, read, a
1414

1515
This guide explains how to integrate the TypeScript PDF library into an TypeScript application.
1616

17+
## Installing Syncfusion<sup>&reg;</sup> JavaScript PDF package
18+
19+
All the available JS 2 packages are published in `npmjs.com` registry.
20+
21+
* To install PDF component, use the following command.
22+
23+
```bash
24+
npm install @syncfusion/ej2-pdf --save
25+
```
26+
N> For data extraction features, you need to install the `@syncfusion/ej2-pdf-data-extract` package as an add-on.
27+
For the TypeScript platform, place the **openjpeg** folder in the same location as your `index.html` file. Ensure that your application includes an `openjpeg` folder under `Scripts` (or any publicly accessible static path). This folder must contain the following:
28+
* `openjpeg.js`
29+
* `openjpeg.wasm`
30+
Along with the PDF file from which you want to extract images.
31+
1732
## Dependencies
1833

1934
The following list of dependencies are required to use the `TypeScript PDF library` component in your application.
@@ -40,12 +55,6 @@ The following list of dependencies are required to use the `TypeScript PDF libra
4055
{% endhighlight %}
4156
{% endtabs %}
4257

43-
N> For the TypeScript platform, place the **openjpeg** folder in the same location as your `index.html` file. Ensure that your application includes an `openjpeg` folder under `Scripts` (or any publicly accessible static path). This folder must contain the following:
44-
* `openjpeg.js`
45-
* `openjpeg.wasm`
46-
47-
Along with the PDF file from which you want to extract images. Keep these files in the same static content area as `ej2.min.js` to ensure proper loading.
48-
4958
* Include the following namespaces in `index.ts` file.
5059

5160
{% tabs %}

Document-Processing/PDF/PDF-Library/javascript/Create-PDF-document-vue.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ All the available JS 2 packages are published in `npmjs.com` registry.
4848
npm install @syncfusion/ej2-pdf --save
4949
```
5050
N> For data extraction features, you need to install the `@syncfusion/ej2-pdf-data-extract` package as an add-on.
51-
5251
* Copy the contents of the openjpeg folder from ./node_modules/@syncfusion/ej2-pdf-data-extract/dist to the public directory using the command:
5352
```bash
5453
cp -R ./node_modules/@syncfusion/ej2-pdf-data-extract/dist/openjpeg public/js/openjpeg
5554
```
5655
* Confirm that there is an 'openjpeg' directory within your public directory, if you extracting images from PDF.
57-
* Validate that your server has been configured to utilize the Content-Type: application/wasm MIME type. Additional information can be found in the [Troubleshooting](./troubleshooting/troubleshooting) section.
56+
* Validate that your server has been configured to utilize the Content-Type: application/wasm MIME type.
5857

5958
* **Create a PDF document** : Add the script in `App.vue` by creating a button and attaching a click event that uses the JavaScript PDF API to generate a PDF document.
6059

Document-Processing/PDF/PDF-Library/javascript/Redaction.md

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ documentation: UG
99

1010
Redacting a PDF is the process of permanently removing sensitive or confidential information from PDF documents. Syncfusion<sup>&reg;</sup> PDF library provides an easy way to redact PDF documents.
1111

12-
N> For data extraction features, you need to install the `@syncfusion/ej2-pdf-data-extract` package as an add-on.
12+
N> For redaction features, you need to install the `@syncfusion/ej2-pdf-data-extract` package as an add-on. Please verify the platform's actual root directory where the `openjpeg` file is extracted. Depending on the platform, the root path may vary. Check which root folder is being used by reviewing the path referenced in the [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-library/javascript/create-pdf-document-asp-net-core) page.
1313

1414
## Removing sensitive content from the PDF document
1515

16-
Redaction permanently removes confidential or sensitive information from a PDF. The `PdfRedactionAnnotation` class allows you to define areas to redact, ensuring the underlying text or image data is completely deleted from the document.
16+
Redaction permanently removes confidential or sensitive information from a PDF. The `PdfRedactor` and `PdfRedactionRegion` classes allow you to mark specific areas and apply irreversible redaction to the document.
1717

1818
{% tabs %}
1919
{% highlight typescript tabtitle="TypeScript" %}
@@ -27,7 +27,6 @@ let redactor: PdfRedactor = new PdfRedactor(document);
2727
// Add redactions to the collection
2828
let redactions: PdfRedactionRegion[] = [];
2929
redactions.push(new PdfRedactionRegion(0, {x: 10, y: 10, width: 100, height: 50}));
30-
redactions.push(new PdfRedactionRegion(2, {x: 10, y: 10, width: 100, height: 50}, true, {r: 255, g: 0, b: 0}));
3130
redactor.add(redactions);
3231
// Apply redactions on the PDF document
3332
redactor.redact();
@@ -45,7 +44,6 @@ var redactor = new ej.pdfdataextract.PdfRedactor(document);
4544
// Add redactions to the collection
4645
var redactions = [];
4746
redactions.push(new PdfRedactionRegion(0, {x: 10, y: 10, width: 100, height: 50}));
48-
redactions.push(new PdfRedactionRegion(2, {x: 10, y: 10, width: 100, height: 50}, true, {r: 255, g: 0, b: 0}));
4947
redactor.add(redactions);
5048
// Apply redactions on the PDF document
5149
redactor.redact();
@@ -67,6 +65,8 @@ import { PdfRedactor, PdfRedactionRegion} from '@syncfusion/ej2-pdf-data-extract
6765

6866
// Load an existing PDF document
6967
let document: PdfDocument = new PdfDocument(data);
68+
// Add redactions to the collection
69+
let redactions: PdfRedactionRegion[] = [];
7070
// Initialize a new instance of the `PdfRedactor` class
7171
let redactor: PdfRedactor = new PdfRedactor(document);
7272
// Initialize a new instance of the `PdfRedactionRegion` class.
@@ -86,6 +86,8 @@ document.destroy();
8686
{% highlight javascript tabtitle="JavaScript" %}
8787
// Load an existing PDF document
8888
var document = new ej.pdf.PdfDocument(data);
89+
// Add redactions to the collection
90+
var redactions = [];
8991
// Initialize a new instance of the `PdfRedactor` class
9092
var redactor = new ej.pdfdataextract.PdfRedactor(document);
9193
// Initialize a new instance of the `PdfRedactionRegion` class.
@@ -104,54 +106,76 @@ document.destroy();
104106
{% endhighlight %}
105107
{% endtabs %}
106108

107-
## Redaction appearance fill color
109+
## Text appearance on the redacted area
108110

109-
Customize the appearance of the redacted area by applying specific fill colors. This helps maintain a consistent design or highlight redacted sections in a visually appealing way.
111+
Customize the redacted region by drawing text or graphics over it, using `PdfRedactionRegion` and `PdfRedactor` to define the area and apply a custom visual appearance to the redaction.
110112

111113
{% tabs %}
112114
{% highlight typescript tabtitle="TypeScript" %}
113115
import { PdfDocument } from '@syncfusion/ej2-pdf';
114116
import { PdfRedactor, PdfRedactionRegion } from '@syncfusion/ej2-pdf-data-extract';
115117

116118
// Load an existing PDF document
117-
let document: PdfDocument = new PdfDocument(data, password);
119+
let document = new PdfDocument(data);
118120
// Add redactions to the collection
119-
let redactions: PdfRedactionRegion[] = [];
120-
// Initialize a new instance of the `PdfRedactor` class
121-
let redactor: PdfRedactor = new PdfRedactor(document);
122-
// Initialize a new instance of the `PdfRedactionRegion` class.
123-
let redaction: PdfRedactionRegion = new PdfRedactionRegion(0, {x: 40, y: 41.809, width: 80, height: 90});
124-
// Sets the fill color used to fill the redacted area.
125-
redaction.fillColor = {r: 255, g: 0, b: 0};
121+
let redactions = [];
122+
let region = { x: 40, y: 43.620000000000005, width: 80, height: 20 };
123+
// Initialize a new redaction region with custom appearance
124+
let redaction = new PdfRedactionRegion(0, { x: 0, y: 0, width: 80, height: 20 }, true);
125+
let font = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
126+
redaction.appearance.normal.graphics.drawString(
127+
'Redacted Text',
128+
font,
129+
{ x: 0, y: 0, width: 80, height: 20 },
130+
new PdfBrush({ r: 255, g: 0, b: 0 })
131+
);
126132
redactions.push(redaction);
127-
// Add redactions with specified options.
133+
// Add another redaction region (example region coordinates)
134+
redaction = new PdfRedactionRegion(0, { x: 0, y: 0, width: 80, height: 20 }, true);
135+
region = { x: 40, y: 43.620000000000005, width: 80, height: 20 };
136+
redactions.push(redaction);
137+
// Initialize a new instance of the PdfRedactor class
138+
let redactor = new PdfRedactor(document);
139+
// Add redactions with specified options
128140
redactor.add(redactions);
129141
// Apply redactions on the PDF document
130142
redactor.redact();
131143
// Save the document
132144
document.save('output.pdf');
133145
// Destroy the document
134146
document.destroy();
147+
135148
{% endhighlight %}
136149
{% highlight javascript tabtitle="JavaScript" %}
137-
// Load an existing PDF document
138-
var document = new ej.pdf.PdfDocument(data, password);
139-
// Add redactions to the collection
150+
151+
// Load an existing PDF document
152+
var document = new ej.pdf.PdfDocument(data);
153+
// Prepare redactions collection
140154
var redactions = [];
141-
// Initialize a new instance of the `PdfRedactor` class
142-
var redactor = new ej.pdfdataextract.PdfRedactor(document);
143-
// Initialize a new instance of the `PdfRedactionRegion` class.
144-
var redaction = new ej.pdfdataextract.PdfRedactionRegion(0, {x: 40, y: 41.809, width: 80, height: 90});
145-
// Sets the fill color used to fill the redacted area.
146-
redaction.fillColor = {r: 255, g: 0, b: 0};
155+
// Example region coordinates (page 0)
156+
var region = { x: 40, y: 43.62, width: 80, height: 20 };
157+
// Create a redaction region with a custom appearance (draw "Redacted Text" in red)
158+
var redaction = new ej.pdf.PdfRedactionRegion(0, { x: 0, y: 0, width: 80, height: 20 }, true);
159+
var font = document.embedFont(PdfFontFamily.helvetica, 10, PdfFontStyle.regular);
160+
// Draw custom appearance on the redaction overlay
161+
redaction.appearance.normal.graphics.drawString(
162+
'Redacted Text',
163+
font,
164+
{ x: 0, y: 0, width: 80, height: 20 },
165+
new ej.pdf.PdfBrush({ r: 255, g: 0, b: 0 })
166+
);
147167
redactions.push(redaction);
148-
// Add redactions with specified options.
168+
// Add another redaction region using the specified coordinates on page 0
169+
redaction = new ej.pdf.PdfRedactionRegion(0, { x: region.x, y: region.y, width: region.width, height: region.height }, true);
170+
redactions.push(redaction);
171+
// Initialize redactor
172+
var redactor = new ej.pdf.PdfRedactor(document);
173+
// Add redactions and apply them
149174
redactor.add(redactions);
150-
// Apply redactions on the PDF document
151175
redactor.redact();
152-
// Save the document
176+
// Save and dispose
153177
document.save('output.pdf');
154-
// Destroy the document
155178
document.destroy();
179+
156180
{% endhighlight %}
157181
{% endtabs %}

0 commit comments

Comments
 (0)