예제 #1
0
        /// <summary>
        /// Perform cleanup of areas of interest on a given
        /// <see cref="iText.Kernel.Pdf.PdfPage"/>
        /// </summary>
        /// <param name="pdfPage">
        /// the
        /// <see cref="iText.Kernel.Pdf.PdfPage"/>
        /// to be redacted
        /// </param>
        public virtual void CleanUp(PdfPage pdfPage)
        {
            IList <PdfCleanUpLocation> cleanUpLocations = GetPdfCleanUpLocations(pdfPage);
            PdfCleanUpTool             cleaner          = (cleanUpLocations == null) ? new PdfCleanUpTool(pdfPage.GetDocument(), true) : new
                                                          PdfCleanUpTool(pdfPage.GetDocument(), cleanUpLocations);

            cleaner.CleanUp();
        }
예제 #2
0
        /// <summary>
        /// Perform cleanup of areas of interest on a given
        /// <see cref="iText.Kernel.Pdf.PdfDocument"/>
        /// </summary>
        /// <param name="pdfDocument">
        /// the
        /// <see cref="iText.Kernel.Pdf.PdfDocument"/>
        /// to be redacted
        /// </param>
        public virtual void CleanUp(PdfDocument pdfDocument)
        {
            IList <PdfCleanUpLocation> cleanUpLocations = GetPdfCleanUpLocations(pdfDocument);
            PdfCleanUpTool             cleaner          = (cleanUpLocations == null) ? new PdfCleanUpTool(pdfDocument, true) : new PdfCleanUpTool
                                                              (pdfDocument, cleanUpLocations);

            cleaner.CleanUp();
        }
예제 #3
0
        private void CleanUp(String input, String output, IList <PdfCleanUpLocation> cleanUpLocations)
        {
            PdfDocument    pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
            PdfCleanUpTool cleaner     = (cleanUpLocations == null) ? new PdfCleanUpTool(pdfDocument, true) : new PdfCleanUpTool
                                             (pdfDocument, cleanUpLocations);

            cleaner.CleanUp();
            pdfDocument.Close();
        }
예제 #4
0
        public static void Remove(PdfDocument pdf, int pageNum, float x, float y, float width, float height)
        {
            PdfPage page = pdf.GetPage(pageNum);

            List <PdfCleanUpLocation> cleanUpLocations = new List <PdfCleanUpLocation> ();

            cleanUpLocations.Add(new PdfCleanUpLocation(pageNum, new Rectangle(x, y, width, height)));
            PdfCleanUpTool cleaner = new PdfCleanUpTool(pdf, cleanUpLocations);

            cleaner.CleanUp();
        }
예제 #5
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));

            // If the second argument is true, then regions to be erased are extracted from the redact annotations
            // contained inside the given document. If the second argument is false (that's default behavior),
            // then use PdfCleanUpTool.addCleanupLocation(PdfCleanUpLocation)
            // method to set regions to be erased from the document.
            PdfCleanUpTool cleaner = new PdfCleanUpTool(pdfDoc, true);

            cleaner.CleanUp();

            pdfDoc.Close();
        }
예제 #6
0
        private static void RunTest(String fileName)
        {
            String input  = inputPath + fileName + ".pdf";
            String output = outputPath + fileName + "_cleaned.pdf";
            String cmp    = inputPath + "cmp_" + fileName + ".pdf";
            IList <PdfCleanUpLocation> cleanUpLocations = JavaCollectionsUtil.SingletonList(new PdfCleanUpLocation(1, new
                                                                                                                   Rectangle(308, 520, 200, 75)));
            PdfDocument    pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
            PdfCleanUpTool cleaner     = new PdfCleanUpTool(pdfDocument, cleanUpLocations);

            cleaner.CleanUp();
            pdfDocument.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(output, cmp, outputPath));
        }
예제 #7
0
        public virtual void ImageTransparencyTextOnTransparentField()
        {
            String fileName = "textOnTransparentField";
            String input    = inputPath + fileName + ".pdf";
            String output   = outputPath + fileName + "_cleaned.pdf";
            String cmp      = inputPath + "cmp_" + fileName + ".pdf";
            IList <PdfCleanUpLocation> cleanUpLocations = JavaCollectionsUtil.SingletonList(new PdfCleanUpLocation(1, new
                                                                                                                   Rectangle(280, 360, 200, 75)));
            PdfDocument    pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
            PdfCleanUpTool cleaner     = new PdfCleanUpTool(pdfDocument, cleanUpLocations);

            cleaner.CleanUp();
            new PdfCanvas(pdfDocument.GetFirstPage().NewContentStreamBefore(), pdfDocument.GetFirstPage().GetResources
                              (), pdfDocument).SetColor(ColorConstants.LIGHT_GRAY, true).Rectangle(0, 0, 1000, 1000).Fill().SetColor
                (ColorConstants.BLACK, true);
            pdfDocument.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(output, cmp, outputPath));
        }
예제 #8
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));

            IList <PdfCleanUpLocation> cleanUpLocations = new List <PdfCleanUpLocation>();

            // The arguments of the PdfCleanUpLocation constructor: the number of page to be cleaned up,
            // a Rectangle defining the area on the page we want to clean up,
            // a color which will be used while filling the cleaned area.
            PdfCleanUpLocation location = new PdfCleanUpLocation(1,
                                                                 new Rectangle(97, 405, 383, 40), ColorConstants.GRAY);

            cleanUpLocations.Add(location);

            PdfCleanUpTool cleaner = new PdfCleanUpTool(pdfDoc, cleanUpLocations);

            cleaner.CleanUp();

            pdfDoc.Close();
        }