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);

        }
        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;
            }
        }
Example #3
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);
        }