private void RemoveFooter(Aspose.Pdf.Document pdfDoc)
        {
            try
            {
                for (int i = 1; i <= pdfDoc.Pages.Count; i++)
                {
                    Page page = pdfDoc.Pages[i];
                    Aspose.Pdf.Rectangle rect  = new Aspose.Pdf.Rectangle(0, 75, page.Rect.Width, 1);
                    RedactionAnnotation  annot = new RedactionAnnotation(page, rect);
                    annot.FillColor   = Aspose.Pdf.Color.White;
                    annot.BorderColor = Aspose.Pdf.Color.Yellow;
                    annot.Color       = Aspose.Pdf.Color.White;

                    annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;
                    page.Annotations.Add(annot);
                    annot.Redact();

                    TextAbsorber textAbsorber = new TextAbsorber();
                    pdfDoc.Pages[i].Accept(textAbsorber);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void Run()
        {
           
            // ExStart:RedactPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open document
            Document doc = new Document(dataDir + "input.pdf");

            // Create RedactionAnnotation instance for specific page region
            RedactionAnnotation annot = new RedactionAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 500, 300, 600));
            annot.FillColor = Aspose.Pdf.Color.Green;
            annot.BorderColor = Aspose.Pdf.Color.Yellow;
            annot.Color = Aspose.Pdf.Color.Blue;
            // Text to be printed on redact annotation
            annot.OverlayText = "REDACTED";
            annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;
            // Repat Overlay text over redact Annotation
            annot.Repeat = true;
            // Add annotation to annotations collection of first page
            doc.Pages[1].Annotations.Add(annot);
            // Flattens annotation and redacts page contents (i.e. removes text and image
            // Under redacted annotation)
            annot.Redact();
            dataDir = dataDir + "RedactPage_out.pdf";
            doc.Save(dataDir);
            // ExEnd:RedactPage
            Console.WriteLine("\nCertain page region with RedactionAnnotation redact successfully.\nFile saved at " + dataDir);

        }
Example #3
0
        public void PutRedactionAnnotationTest()
        {
            RedactionAnnotation annotation = new RedactionAnnotation()
            {
                Name  = "Updated Test",
                Rect  = new Rectangle(100, 100, 200, 200),
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                ZIndex    = 1,
                QuadPoint = new List <Point>
                {
                    new Point(10, 20)
                },
                Modified = "01/01/2018 00:00:00.000 AM"
            };

            var    lineResponse = api.GetDocumentRedactionAnnotations(Name, folder: FolderName);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = api.PutRedactionAnnotation(Name, annotationId, annotation, folder: FolderName);

            Console.WriteLine(response);
        }
Example #4
0
        public static void Run()
        {
            // ExStart:RedactPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open document
            Document doc = new Document(dataDir + "input.pdf");

            // Create RedactionAnnotation instance for specific page region
            RedactionAnnotation annot = new RedactionAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 500, 300, 600));

            annot.FillColor   = Aspose.Pdf.Color.Green;
            annot.BorderColor = Aspose.Pdf.Color.Yellow;
            annot.Color       = Aspose.Pdf.Color.Blue;
            // Text to be printed on redact annotation
            annot.OverlayText   = "REDACTED";
            annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;
            // Repat Overlay text over redact Annotation
            annot.Repeat = true;
            // Add annotation to annotations collection of first page
            doc.Pages[1].Annotations.Add(annot);
            // Flattens annotation and redacts page contents (i.e. removes text and image
            // under redacted annotation)
            annot.Redact();
            dataDir = dataDir + "RedactPage_out_.pdf";
            doc.Save(dataDir);
            // ExEnd:RedactPage
            Console.WriteLine("\nCertain page region with RedactionAnnotation redact successfully.\nFile saved at " + dataDir);
        }
        public void PutRedactionAnnotationTest()
        {
            RedactionAnnotation annotation = new RedactionAnnotation(Rect: new Rectangle(100, 100, 200, 200))
            {
                Name  = "Updated Test",
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                ZIndex    = 1,
                QuadPoint = new List <Point>
                {
                    new Point(10, 20)
                },
                Modified = "01/01/2018 00:00:00.000 AM"
            };

            var    lineResponse = PdfApi.GetDocumentRedactionAnnotations(Name, folder: TempFolder);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = PdfApi.PutRedactionAnnotation(Name, annotationId, annotation, folder: TempFolder);

            Assert.That(response.Code, Is.EqualTo(200));
        }