1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6(exports => {
7 exports.runPDFRedactTest = () => {
8 const PDFNet = exports.Core.PDFNet;
9
10 const main = async () => {
11 // Relative path to the folder containing test files.
12 const inputPath = '../TestFiles/';
13 try {
14 const doc = await PDFNet.PDFDoc.createFromURL(inputPath + 'newsletter.pdf');
15 doc.initSecurityHandler();
16 doc.lock();
17
18 const redactionArray = []; // we will contain a list of redaction objects in this array
19 redactionArray.push(await PDFNet.Redactor.redactionCreate(1, await PDFNet.Rect.init(100, 100, 550, 600), false, 'Top Secret'));
20 redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(30, 30, 450, 450), true, 'Negative Redaction'));
21 redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(0, 0, 100, 100), false, 'Positive'));
22 redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(100, 100, 200, 200), false, 'Positive'));
23 redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(300, 300, 400, 400), false, ''));
24 redactionArray.push(await PDFNet.Redactor.redactionCreate(2, await PDFNet.Rect.init(500, 500, 600, 600), false, ''));
25 redactionArray.push(await PDFNet.Redactor.redactionCreate(3, await PDFNet.Rect.init(0, 0, 700, 20), false, ''));
26
27 const blue = await PDFNet.ColorPt.init(0.1, 0.2, 0.6, 0);
28 const timesFont = await PDFNet.Font.create(doc, PDFNet.Font.StandardType1Font.e_times_roman);
29 const appear = { redaction_overlay: true, positive_overlay_color: blue, border: false, font: timesFont, show_redacted_content_regions: true };
30 PDFNet.Redactor.redact(doc, redactionArray, appear, false, false);
31
32 const docbuf = await doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
33 saveBufferAsPDFDoc(docbuf, 'redacted.pdf');
34 console.log('Done...');
35 } catch (err) {
36 console.log(err.stack);
37 }
38 };
39 // add your own license key as the second parameter, e.g. PDFNet.runWithCleanup(main, 'YOUR_LICENSE_KEY')
40 PDFNet.runWithCleanup(main);
41 };
42})(window);
43// eslint-disable-next-line spaced-comment
44//# sourceURL=PDFRedactTest.js