Esempio n. 1
0
        public async Task Can_use_local_file_paths_for_both_document_and_markup_JSON()
        {
            // Arrange
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();

            // Act
            RemoteWorkFile result = await prizmDocServer.BurnMarkupAsync("documents/confidential-contacts.pdf", "documents/confidential-contacts.pdf.markup.json");

            // Assert
            await result.SaveAsync("burned.pdf");

            await this.AssertRedactionOccurredFor(result);
        }
Esempio n. 2
0
        public async Task UploadAsync_with_local_file_path_followed_by_SaveAsync_roundtrip_works()
        {
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();

            const string INPUT_FILENAME  = "documents/example.docx";
            const string OUTPUT_FILENAME = "downloaded.docx";

            RemoteWorkFile remoteWorkFile = await prizmDocServer.UploadAsync(INPUT_FILENAME);

            await remoteWorkFile.SaveAsync(OUTPUT_FILENAME);

            CollectionAssert.AreEqual(File.ReadAllBytes(INPUT_FILENAME), File.ReadAllBytes(OUTPUT_FILENAME));
        }
Esempio n. 3
0
        public async Task Can_use_RemoteWorkFile_for_document_and_local_file_path_for_markup_JSON()
        {
            // Arrange
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();

            AffinitySession affinitySession = Util.RestClient.CreateAffinitySession();
            RemoteWorkFile  document        = await affinitySession.UploadAsync("documents/confidential-contacts.pdf");

            // Act
            RemoteWorkFile result = await prizmDocServer.BurnMarkupAsync(document, "documents/confidential-contacts.pdf.markup.json");

            // Assert
            await result.SaveAsync("burned.pdf");

            await this.AssertRedactionOccurredFor(result);
        }
Esempio n. 4
0
        public async Task Can_use_RemoteWorkFile_instances_with_different_affinity()
        {
            // Arrange
            PrizmDocServerClient prizmDocServer = Util.CreatePrizmDocServerClient();

            AffinitySession session1 = Util.RestClient.CreateAffinitySession();
            AffinitySession session2 = Util.RestClient.CreateAffinitySession();

            RemoteWorkFile document = await session1.UploadAsync("documents/confidential-contacts.pdf");

            RemoteWorkFile markupJson = await session2.UploadAsync("documents/confidential-contacts.pdf.markup.json");

            Assert.AreNotEqual(document.AffinityToken, markupJson.AffinityToken);

            // Act
            RemoteWorkFile result = await prizmDocServer.BurnMarkupAsync(document, markupJson);

            // Assert
            await result.SaveAsync("burned.pdf");

            await this.AssertRedactionOccurredFor(result);
        }
Esempio n. 5
0
        private static async Task MainAsync()
        {
            // Delete any existing output file before we get started.
            File.Delete("redacted.pdf");

            var prizmDocServer = new PrizmDocServerClient(Environment.GetEnvironmentVariable("BASE_URL"), Environment.GetEnvironmentVariable("API_KEY"));

            // -----------------------------------------------------------------
            // Step 1: Create markup JSON containing definitions of the areas we
            //         want to redact.
            // -----------------------------------------------------------------

            // Define a rule which will create a redaction for any text in a
            // document which looks like a social security number (###-##-####),
            // and use the text "(b)(6)" in the center of the redaction
            // rectangle as the reason for redaction.
            var ssnRule = new RegexRedactionMatchRule(@"\d\d\d-\d\d-\d\d\d\d")
            {
                RedactWith = new RedactionCreationOptions()
                {
                    Reason = "(b)(6)",
                },
            };

            // Define a rule which will create a redaction for any text in a
            // document which looks like an email address (this is a very basic
            // regex, matching things like [email protected]) and use the
            // text "(b)(6)" in the center of the redaction rectangle as
            // the reason for redaction.
            var emailRule = new RegexRedactionMatchRule(@"\S+@\S+\.\S+")
            {
                RedactWith = new RedactionCreationOptions()
                {
                    Reason = "(b)(6)",
                },
            };

            // Define a rule which will create a redaction for all occurrences
            // of "Bruce Wayne" in a document, use the text "(b)(1)" in the
            // center of the redaction rectangle as the reason for redaction,
            // customize various colors used, and attach some arbitrary
            // key/value string data to all redaction definitions which are
            // created. This arbitrary data will be present in the output markup
            // JSON file.
            var bruceWayneRule = new RegexRedactionMatchRule(@"Bruce Wayne")
            {
                RedactWith = new RedactionCreationOptions()
                {
                    Reason          = "(b)(1)",
                    FontColor       = "#FDE311",
                    FillColor       = "#000080",
                    BorderColor     = "#000000",
                    BorderThickness = 2,

                    // This arbitrary data will simply be present in the generated markup JSON.
                    Data = new Dictionary <string, string>
                    {
                        { "arbitrary-key-1", "arbitrary-value-1" },
                        { "arbitrary-key-2", "arbitrary-value-2" },
                    },
                },
            };

            var rules = new[] { ssnRule, emailRule, bruceWayneRule };

            // Automatically create a markup.json file with redaction
            // definitions based upon regular expression rules for a given
            // document. Any text in the document which matches one of the regex
            // rules will have a redaction definition created for that portion
            // of the document. The output markup.json file with its redaction
            // definitions can later be burned into the document.
            RemoteWorkFile markupJson = await prizmDocServer.CreateRedactionsAsync("confidential-contacts.pdf", rules);

            // -----------------------------------------------------------------
            // Step 2: Burn the markup JSON into the original document,
            //         producing a new, redacted PDF.
            // -----------------------------------------------------------------
            RemoteWorkFile redactedPdf = await prizmDocServer.BurnMarkupAsync("confidential-contacts.pdf", markupJson);

            // Save the result to "redacted.pdf"
            await redactedPdf.SaveAsync("redacted.pdf");
        }