public virtual void CleanUpRedactAnnotationsWithAdditionalLocationSendsCoreAndCleanUpEventTest()
        {
            ByteArrayOutputStream baos     = new ByteArrayOutputStream();
            PdfDocument           document = new PdfDocument(new PdfReader(INPUT_PATH + "absentICentry.pdf"), new PdfWriter(baos
                                                                                                                            ));
            String oldProducer = document.GetDocumentInfo().GetProducer();
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation
                                                                                     >();

            iText.PdfCleanup.PdfCleanUpLocation lineLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(100
                                                                                                                   , 560, 200, 30), ColorConstants.GREEN);
            cleanUpLocations.Add(lineLoc);
            PdfCleaner.CleanUpRedactAnnotations(document, cleanUpLocations);
            document.Close();
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(2, events.Count);
            NUnit.Framework.Assert.AreEqual(ITextCoreProductEvent.PROCESS_PDF, events[0].GetEvent().GetEventType());
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[1].GetEvent().GetEventType());
            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new MemoryStream(baos.ToArray())))) {
                String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCoreEvent(), GetCleanUpEvent
                                                                                                       () }, oldProducer);
                NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer());
            }
        }
        public virtual void CleanUpWithStreamArgumentsSendsCleanUpEventTest()
        {
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation
                                                                                     >();

            iText.PdfCleanup.PdfCleanUpLocation lineLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(100
                                                                                                                   , 560, 200, 30));
            cleanUpLocations.Add(lineLoc);
            String @in    = INPUT_PATH + "page229.pdf";
            String @out   = OUTPUT_PATH + "cleanUpWithStreamArgumentTest.pdf";
            Stream file   = new FileStream(@in, FileMode.Open, FileAccess.Read);
            Stream output = new FileStream(@out, FileMode.Create);

            PdfCleaner.CleanUp(file, output, cleanUpLocations, new CleanUpProperties());
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(1, events.Count);
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[0].GetEvent().GetEventType());
            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(@out))) {
                using (PdfDocument inputDoc = new PdfDocument(new PdfReader(@in))) {
                    String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCleanUpEvent() }, inputDoc
                                                                         .GetDocumentInfo().GetProducer());
                    NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer());
                }
            }
        }
Example #3
0
        public void TestPdfCleaner()
        {
            PdfCompiler m = new PdfCompiler("c:\\ds21vuoto.pdf", "c:\\ds21prova3.pdf");

            m.Setup();
            m.SetCampo("datanascita", "2/10/1984");
            m.SetCampo("nome", "paolo");
            m.Compile();
            m.Dispose();

            PdfCleaner n = new PdfCleaner("c:\\ds21prova3.pdf");

            n.Setup();
            n.CleanAllFields();

            n.Dispose();

            PdfDescriber c = new PdfDescriber("c:\\ds21prova3.pdf");

            c.Setup();
            System.Collections.Hashtable arr = c.GetFieldsInfoToHashtable();
            foreach (DictionaryEntry elem in arr)
            {
                Assert.AreEqual(c.GetField(elem.Key.ToString()), "");
            }

            c.Dispose();
            File.Delete("c:\\ds21prova3.pdf");
        }
Example #4
0
        public virtual void RedactIPhoneUserManual()
        {
            String input  = inputPath + "iphone_user_guide_untagged.pdf";
            String output = outputPath + "redactIPhoneUserManual.pdf";
            String cmp    = inputPath + "cmp_redactIPhoneUserManual.pdf";
            CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();

            strategy.Add(new RegexBasedCleanupStrategy("(iphone)|(iPhone)"));
            PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            // sweep
            PdfCleaner.AutoSweepCleanUp(pdf, strategy);
            pdf.Close();
            // compare
            CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
            String errorMessage = cmpTool.ExtractAndCompareImages(output, cmp, outputPath, "4");
            // TODO DEVSIX-4047 Switch to compareByContent() when the ticket will be resolved
            String compareByContentResult = cmpTool.CompareVisually(output, cmp, outputPath, "diff_redactIPhoneUserManual_"
                                                                    , cmpTool.GetIgnoredImagesAreas());

            if (compareByContentResult != null)
            {
                errorMessage += compareByContentResult;
            }
            if (!errorMessage.Equals(""))
            {
                NUnit.Framework.Assert.Fail(errorMessage);
            }
        }
        private void CleanUp(String input, String output, IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations
                             )
        {
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            pdfDocument.Close();
        }
 private static void CleanFirstPageAndDrawCleanupRegion(Rectangle cleanupRegion, String input, String output
                                                        )
 {
     using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output))) {
         PdfCleaner.CleanUp(pdfDocument, JavaCollectionsUtil.SingletonList(new iText.PdfCleanup.PdfCleanUpLocation(
                                                                               1, cleanupRegion)));
         DrawCleanupRegionOnPage(pdfDocument, cleanupRegion);
     }
 }
Example #7
0
 public void TestSimpleClean()
 {
     string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
     using (TempFile tf = new TempFile(testDoc))
     {
         string initialHash = tf.MD5Sum;
         IPdfCleaner c = new PdfCleaner();
         c.CleanFile(tf.FilePath);
         string newHash = tf.MD5Sum;
         Assert.AreNotEqual(initialHash, newHash, "We expected the Cleanion to change the file contents");
     }
 }
        private byte[] RemoverCarimboLateral(byte[] arquivo, float largura, float limiteMaximo)
        {
            using MemoryStream readingStream = new MemoryStream(arquivo);
            using PdfReader pdfReader        = new PdfReader(readingStream);

            using MemoryStream writingStream = new MemoryStream();
            using PdfWriter pdfWriter        = new PdfWriter(writingStream);

            using PdfDocument pdfDocument = new PdfDocument(pdfReader, pdfWriter);

            int numberOfPages = pdfDocument.GetNumberOfPages();

            for (int i = 1; i <= numberOfPages; i++)
            {
                PdfPage page = pdfDocument.GetPage(i);
                page.SetIgnorePageRotationForContent(true);
                Rectangle pageSize = pdfDocument.GetPage(i).GetPageSizeWithRotation();

                float offset = pageSize.GetWidth() * largura;
                if (offset > limiteMaximo)
                {
                    offset = limiteMaximo;
                }

                float numeroLinhas    = 4f;
                float intervalo       = offset / (numeroLinhas + 1f);
                float posicaoIncicial = pageSize.GetWidth() - offset;

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

                for (int j = 1; j <= numeroLinhas; j++)
                {
                    Rectangle rectangle = new Rectangle(
                        posicaoIncicial + intervalo, 0,
                        0.1f, pageSize.GetHeight()
                        );

                    PdfCleanUpLocation location = new PdfCleanUpLocation(i, rectangle);

                    posicaoIncicial = posicaoIncicial + intervalo;

                    cleanUpLocations.Add(location);
                }

                PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            }

            pdfDocument.Close();

            return(writingStream.ToArray());
        }
        private void CleanUp(String input, String output, IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations
                             )
        {
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            if (cleanUpLocations == null)
            {
                PdfCleaner.CleanUpRedactAnnotations(pdfDocument);
            }
            else
            {
                PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            }
            pdfDocument.Close();
        }
Example #10
0
        public virtual void RedactIPhoneUserManualColored()
        {
            String input  = inputPath + "iphone_user_guide_untagged_small.pdf";
            String output = outputPath + "redactIPhoneUserManualColored.pdf";
            String cmp    = inputPath + "cmp_redactIPhoneUserManualColored.pdf";
            CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();

            strategy.Add(new RegexBasedCleanupStrategy("(iphone)|(iPhone)").SetRedactionColor(ColorConstants.GREEN));
            PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            // sweep
            PdfCleaner.AutoSweepCleanUp(pdf, strategy);
            pdf.Close();
            CompareResults(cmp, output, outputPath, "4");
        }
 public virtual void CleanCircularReferencesInResourcesTest()
 {
     NUnit.Framework.Assert.That(() => {
         String input            = inputPath + "circularReferencesInResources.pdf";
         PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(new MemoryStream()));
         IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation
                                                                                  >();
         cleanUpLocations.Add(new iText.PdfCleanup.PdfCleanUpLocation(1, pdfDocument.GetPage(1).GetPageSize(), null
                                                                      ));
         PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
         pdfDocument.Close();
     }
                                 , NUnit.Framework.Throws.InstanceOf <OutOfMemoryException>())
     ;
 }
Example #12
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 <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = JavaCollectionsUtil.SingletonList(new iText.PdfCleanup.PdfCleanUpLocation
                                                                                                                 (1, new Rectangle(280, 360, 200, 75)));
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            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));
        }
Example #13
0
 public void TestSimpleCleanTo()
 {
     string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
     using (TempFile tf = new TempFile(testDoc))
     {
         using (TempFile dest = new TempFile())
         {
             File.Delete(dest.FilePath);
             string initialHash = tf.MD5Sum;
             IPdfCleaner c = new PdfCleaner();
             c.CleanFileTo(tf.FilePath, dest.FilePath);
             Assert.IsTrue(File.Exists(dest.FilePath), "We expected the dest file to be created");
             string newHash = dest.MD5Sum;
             Assert.AreNotEqual(initialHash, newHash, "We expected the Cleanion to change the file contents");
         }
     }
 }
        public virtual void CleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest()
        {
            Stream inputStream  = new FileStream(INPUT_PATH + "absentICentry.pdf", FileMode.Open, FileAccess.Read);
            Stream outputStream = new FileStream(OUTPUT_PATH + "cleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest.pdf"
                                                 , FileMode.Create);
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation
                                                                                     >();

            iText.PdfCleanup.PdfCleanUpLocation lineLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(100
                                                                                                                   , 560, 200, 30), ColorConstants.GREEN);
            cleanUpLocations.Add(lineLoc);
            PdfCleaner.CleanUpRedactAnnotations(inputStream, outputStream, cleanUpLocations);
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(1, events.Count);
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[0].GetEvent().GetEventType());
        }
Example #15
0
        public virtual void CleanUpAreaCalculationPrecisionTest()
        {
            String input  = inputPath + "cleanUpAreaCalculationPrecision.pdf";
            String output = outputPath + "cleanUpAreaCalculationPrecision.pdf";
            String cmp    = inputPath + "cmp_cleanUpAreaCalculationPrecision.pdf";
            CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();

            strategy.Add(new CustomLocationExtractionStrategy("(iphone)|(iPhone)"));
            PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            // sweep
            PdfCleaner.AutoSweepCleanUp(pdf, strategy);
            pdf.Close();
            // compare
            CompareTool compareTool  = new CompareTool();
            String      errorMessage = compareTool.CompareByContent(output, cmp, outputPath);

            NUnit.Framework.Assert.IsNull(errorMessage);
        }
        public virtual void CleanUpRedactAnnotationsWithStreamArgumentsSendsCleanUpEventTest()
        {
            String @in    = INPUT_PATH + "absentICentry.pdf";
            String @out   = OUTPUT_PATH + "cleanUpRedactAnnotationsWithStreamArgumentTest.pdf";
            Stream file   = new FileStream(@in, FileMode.Open, FileAccess.Read);
            Stream output = new FileStream(@out, FileMode.Create);

            PdfCleaner.CleanUpRedactAnnotations(file, output);
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(1, events.Count);
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[0].GetEvent().GetEventType());
            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(@out))) {
                using (PdfDocument inputDoc = new PdfDocument(new PdfReader(@in))) {
                    String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCleanUpEvent() }, inputDoc
                                                                         .GetDocumentInfo().GetProducer());
                    NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer());
                }
            }
        }
Example #17
0
        public void TestMissingInputFile()
        {
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\i_do_not_exist.pdf");
            using (TempFile dest = new TempFile())
            {
                File.Delete(dest.FilePath);
                PdfCleaner r = new PdfCleaner();
                try
                {
                    r.CleanFileTo(testDoc, dest.FilePath);
                    Assert.Fail("We expected not to get here - should have thrown an exception");
                }
                catch (Exception e)
                {
                    Assert.IsInstanceOf(typeof(FileNotFoundException), e);
                }
                Assert.IsFalse(File.Exists(dest.FilePath), "We expected the dest file not to be created");
            }

        }
Example #18
0
        public virtual void RedactTonySoprano()
        {
            String input  = inputPath + "TheSopranos.pdf";
            String output = outputPath + "redactTonySoprano.pdf";
            String cmp    = inputPath + "cmp_redactTonySoprano.pdf";
            CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();

            strategy.Add(new RegexBasedCleanupStrategy("Tony( |_)Soprano"));
            strategy.Add(new RegexBasedCleanupStrategy("Soprano"));
            strategy.Add(new RegexBasedCleanupStrategy("Sopranos"));
            PdfWriter writer = new PdfWriter(output);

            writer.SetCompressionLevel(0);
            PdfDocument pdf = new PdfDocument(new PdfReader(input), writer);

            // sweep
            PdfCleaner.AutoSweepCleanUp(pdf, strategy);
            pdf.Close();
            // compare
            CompareResults(cmp, output, outputPath, "4");
        }
        public virtual void AutoCleanWithStreamParamsSendsCleanUpEventTest()
        {
            String input  = INPUT_PATH + "fontCleanup.pdf";
            String output = OUTPUT_PATH + "autoCleanWithStreamParamsSendsCleanUpEventTest.pdf";
            CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();

            strategy.Add(new RegexBasedCleanupStrategy("leonard"));
            PdfCleaner.AutoSweepCleanUp(new FileStream(input, FileMode.Open, FileAccess.Read), new FileStream(output,
                                                                                                              FileMode.Create), strategy);
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(1, events.Count);
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[0].GetEvent().GetEventType());
            using (PdfDocument outDoc = new PdfDocument(new PdfReader(output))) {
                using (PdfDocument inputDoc = new PdfDocument(new PdfReader(input))) {
                    String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCleanUpEvent() }, inputDoc
                                                                         .GetDocumentInfo().GetProducer());
                    NUnit.Framework.Assert.AreEqual(expectedProdLine, outDoc.GetDocumentInfo().GetProducer());
                }
            }
        }
        public virtual void AutoSweepCleanUpSendsCoreAndCleanUpEventsTest()
        {
            ByteArrayOutputStream    baos     = new ByteArrayOutputStream();
            PdfDocument              document = new PdfDocument(new PdfReader(INPUT_PATH + "fontCleanup.pdf"), new PdfWriter(baos));
            CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();

            strategy.Add(new RegexBasedCleanupStrategy("leonard"));
            PdfCleaner.AutoSweepCleanUp(document, strategy);
            String oldProducer = document.GetDocumentInfo().GetProducer();

            document.Close();
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(2, events.Count);
            NUnit.Framework.Assert.AreEqual(ITextCoreProductEvent.PROCESS_PDF, events[0].GetEvent().GetEventType());
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[1].GetEvent().GetEventType());
            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new MemoryStream(baos.ToArray())))) {
                String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCoreEvent(), GetCleanUpEvent
                                                                                                       () }, oldProducer);
                NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer());
            }
        }
        public virtual void NoWhiteColorTest()
        {
            String input  = inputPath + "indexedImageNoWhite.pdf";
            String output = outputPath + "indexedImageNoWhite.pdf";
            String cmp    = inputPath + "cmp_indexedImageNoWhite.pdf";

            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output))) {
                PdfCleaner.CleanUp(pdfDocument, JavaUtil.ArraysAsList(new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle
                                                                                                                  (150, 250, 100, 100))));
            }

            /*
             * Result in Java and .NET is different.
             *
             * Java is able to process images with indexed colorspace same as others and
             * doesn't preserve indexed colorspace. .NET requires special processing for
             * indexed colorspace images, but preserves indexed colorspace.
             *
             * In .NET color of cleaned area is the first color of indexed color palette.
             * In Java color of cleaned area is white.
             */
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(output, cmp, outputPath));
        }
Example #22
0
        private static void RunTest(String fileName, String fuzzValue)
        {
            String input  = inputPath + fileName + ".pdf";
            String output = outputPath + fileName + "_cleaned.pdf";
            String cmp    = inputPath + "cmp_" + fileName + ".pdf";
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = JavaCollectionsUtil.SingletonList(new iText.PdfCleanup.PdfCleanUpLocation
                                                                                                                 (1, new Rectangle(308, 520, 200, 75)));
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            pdfDocument.Close();
            CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
            String errorMessage           = cmpTool.ExtractAndCompareImages(output, cmp, outputPath, fuzzValue);
            String compareByContentResult = cmpTool.CompareByContent(output, cmp, outputPath);

            if (compareByContentResult != null)
            {
                errorMessage += compareByContentResult;
            }
            if (!errorMessage.Equals(""))
            {
                NUnit.Framework.Assert.Fail(errorMessage);
            }
        }
Example #23
0
 public void TestBadOutputFile()
 {
     string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
     using (TempFile tf = new TempFile(testDoc))
     {
         PdfCleaner r = new PdfCleaner();
         try
         {
             r.CleanFileTo(tf.FilePath, "q:\\blah\\no\\existy\\here.pdf");
             Assert.Fail("We expected not to get here - should have thrown an exception");
         }
         catch (Exception e)
         {
             //Assert.IsInstanceOf(typeof(IOException), e);
         }
     }
 }
Example #24
0
 public void TestRelativePath()
 {
     IPdfCleaner c = new PdfCleaner();
     c.CleanFile("test.pdf");
 }
Example #25
0
 public void TestRelativePath3()
 {
     string outputDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\output.pdf");
     IPdfCleaner c = new PdfCleaner();
     c.CleanFileTo("test.doc", outputDoc);
 }
Example #26
0
        public void TestLockedInputFile()
        {
            string testDoc = TestUtils.TestFileUtils.MakeRootPathAbsolute(@"Projects\Workshare.API\Workshare.API.Tests\TestDocs\test.pdf");
            using (TempFile tf = new TempFile(testDoc))
            using (TempFile dest = new TempFile())
            {
                File.Delete(dest.FilePath);
                using (Stream s = File.Open(tf.FilePath, FileMode.Open, FileAccess.ReadWrite))
                {
                    PdfCleaner r = new PdfCleaner();
                    try
                    {
                        r.CleanFileTo(tf.FilePath, dest.FilePath);
                        Assert.Fail("We expected not to get here - should have thrown an exception");
                    }
                    catch (Exception e)
                    {
                        //Assert.IsInstanceOf(typeof(IOException), e);
                    }
                    Assert.IsFalse(File.Exists(dest.FilePath), "We expected the dest file not to be created");
                }
            }

        }
Example #27
0
 private void CleanUp(PdfDocument pdfDocument, IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations)
 {
     PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
     pdfDocument.Close();
 }