Пример #1
0
        public virtual void VerifyPagesAreNotReadOnOpenTest()
        {
            String srcFile = sourceFolder + "taggedOnePage.pdf";

            PdfPagesTest.CustomPdfReader reader = new PdfPagesTest.CustomPdfReader(this, srcFile);
            PdfDocument document = new PdfDocument(reader);

            document.Close();
            NUnit.Framework.Assert.IsFalse(reader.pagesAreRead);
        }
Пример #2
0
        public virtual void ReadSinglePageTest()
        {
            String srcFile = sourceFolder + "allPagesAreLeaves.pdf";

            PdfPagesTest.CustomPdfReader reader = new PdfPagesTest.CustomPdfReader(this, srcFile);
            reader.SetMemorySavingMode(true);
            PdfDocument document        = new PdfDocument(reader);
            int         amountOfPages   = document.GetNumberOfPages();
            PdfPages    pdfPages        = document.catalog.GetPageTree().GetRoot();
            PdfArray    pageIndRefArray = ((PdfDictionary)pdfPages.GetPdfObject()).GetAsArray(PdfName.Kids);

            document.GetPage(amountOfPages);
            NUnit.Framework.Assert.AreEqual(1, GetAmountOfReadPages(pageIndRefArray));
            document.GetPage(amountOfPages / 2);
            NUnit.Framework.Assert.AreEqual(2, GetAmountOfReadPages(pageIndRefArray));
            document.GetPage(1);
            NUnit.Framework.Assert.AreEqual(3, GetAmountOfReadPages(pageIndRefArray));
            document.Close();
        }
Пример #3
0
        public virtual void ReadPagesInBlocksTest()
        {
            String srcFile = sourceFolder + "docWithBalancedPageTree.pdf";
            int    maxAmountOfPagesReadAtATime = 0;

            PdfPagesTest.CustomPdfReader reader = new PdfPagesTest.CustomPdfReader(this, srcFile);
            PdfDocument document = new PdfDocument(reader);

            for (int page = 1; page <= document.GetNumberOfPages(); page++)
            {
                document.GetPage(page);
                if (reader.numOfPagesRead > maxAmountOfPagesReadAtATime)
                {
                    maxAmountOfPagesReadAtATime = reader.numOfPagesRead;
                }
                reader.numOfPagesRead = 0;
            }
            NUnit.Framework.Assert.AreEqual(111, document.GetNumberOfPages());
            NUnit.Framework.Assert.AreEqual(10, maxAmountOfPagesReadAtATime);
            document.Close();
        }