private void CleanUp(String input, String output, IList <PdfCleanUpLocation> cleanUpLocations)
        {
            PdfDocument    pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
            PdfCleanUpTool cleaner     = new PdfCleanUpTool(pdfDocument, cleanUpLocations);

            cleaner.CleanUp();
            pdfDocument.Close();
        }
 public virtual void SimpleCleanUpOnRotatedPagesIgnoreRotation()
 {
     String fileName = "simpleCleanUpOnRotatedPagesIgnoreRotation";
     String input = inputPath + "documentWithRotatedPages.pdf";
     String output = outputPath + fileName + ".pdf";
     String cmp = inputPath + "cmp_" + fileName + ".pdf";
     PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
     IList<PdfCleanUpLocation> locationsList = new List<PdfCleanUpLocation>();
     for (int i = 0; i < 4; i++) {
         locationsList.Add(new PdfCleanUpLocation(i + 1, Rectangle.GetRectangleOnRotatedPage(new Rectangle(100, 100
             , 200, 100), pdfDocument.GetPage(i + 1)), ColorConstants.GREEN));
     }
     PdfCleanUpTool cleaner = new PdfCleanUpTool(pdfDocument, locationsList);
     cleaner.CleanUp();
     pdfDocument.Close();
     CompareByContent(cmp, output, outputPath, "diff_pathAndIncorrectCMTest");
 }
        public virtual void FilteredImagesCacheFlushingTest02()
        {
            String         input       = inputPath + "severalImageXObjectOccurrences.pdf";
            String         output      = outputPath + "filteredImagesCacheFlushingTest02.pdf";
            String         cmp         = inputPath + "cmp_filteredImagesCacheFlushingTest02.pdf";
            PdfDocument    pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
            PdfCleanUpTool cleanUpTool = new PdfCleanUpTool(pdfDocument);

            cleanUpTool.AddCleanupLocation(new PdfCleanUpLocation(1, new Rectangle(150, 300, 300, 150)));
            cleanUpTool.CleanUp();
            PdfImageXObject img = pdfDocument.GetPage(1).GetResources().GetImage(new PdfName("Im1"));

            img.MakeIndirect(pdfDocument).Flush();
            cleanUpTool.AddCleanupLocation(new PdfCleanUpLocation(2, new Rectangle(150, 300, 300, 150)));
            cleanUpTool.CleanUp();
            cleanUpTool.AddCleanupLocation(new PdfCleanUpLocation(3, new Rectangle(150, 300, 300, 150)));
            cleanUpTool.CleanUp();
            pdfDocument.Close();
            CompareByContent(cmp, output, outputPath, "diff");
            AssertNumberXObjects(output, 1);
        }