Beispiel #1
0
        public virtual void AddCustomAfter()
        {
            PageRange range = new PageRange();

            range.AddPageRangePart(new PageRange.PageRangePartAfter(3));
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(5), JavaUtil.ArraysAsList(3, 4, 5));
        }
Beispiel #2
0
        public virtual void AddSingle()
        {
            PageRange range = new PageRange();

            range.AddSinglePage(5);
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(10), JavaUtil.ArraysAsList(5));
        }
Beispiel #3
0
        public virtual void AddSequenceAndSingleConstructor()
        {
            PageRange range = new PageRange("22-27,25");

            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(30), JavaUtil.ArraysAsList(22, 23, 24, 25, 26,
                                                                                                   27, 25));
        }
Beispiel #4
0
        public virtual void AddCustomAndConstructor()
        {
            PageRange range = new PageRange("odd & 2-14");

            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(15), JavaUtil.ArraysAsList(3, 5, 7, 9, 11, 13)
                                            );
        }
Beispiel #5
0
        public virtual void AddSingleAndSequenceConstructor()
        {
            PageRange range = new PageRange("5, 3-8");

            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(10), JavaUtil.ArraysAsList(5, 3, 4, 5, 6, 7, 8
                                                                                                   ));
        }
Beispiel #6
0
        public virtual void AddCustomEven()
        {
            PageRange range = new PageRange();

            range.AddPageRangePart(PageRange.PageRangePartOddEven.EVEN);
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(5), JavaUtil.ArraysAsList(2, 4));
        }
Beispiel #7
0
        public virtual void AddSequenceConstructor()
        {
            PageRange range = new PageRange("11-19");

            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(16), JavaUtil.ArraysAsList(11, 12, 13, 14, 15,
                                                                                                   16));
        }
Beispiel #8
0
        public virtual void AddSequence()
        {
            PageRange range = new PageRange();

            range.AddPageSequence(11, 19);
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(16), JavaUtil.ArraysAsList(11, 12, 13, 14, 15,
                                                                                                   16));
        }
Beispiel #9
0
        public virtual void AddSingleAndSequence()
        {
            PageRange range = new PageRange();

            range.AddSinglePage(5);
            range.AddPageSequence(3, 8);
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(10), JavaUtil.ArraysAsList(5, 3, 4, 5, 6, 7, 8
                                                                                                   ));
        }
Beispiel #10
0
        public virtual void AddSequenceAndSingle()
        {
            PageRange range = new PageRange();

            range.AddPageSequence(22, 27);
            range.AddSinglePage(25);
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(30), JavaUtil.ArraysAsList(22, 23, 24, 25, 26,
                                                                                                   27, 25));
        }
Beispiel #11
0
        public virtual void AddCustomAnd()
        {
            PageRange range = new PageRange();

            PageRange.IPageRangePart odd = PageRange.PageRangePartOddEven.ODD;
            PageRange.IPageRangePart seq = new PageRange.PageRangePartSequence(2, 14);
            PageRange.IPageRangePart and = new PageRange.PageRangePartAnd(odd, seq);
            range.AddPageRangePart(and);
            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(15), JavaUtil.ArraysAsList(3, 5, 7, 9, 11, 13)
                                            );
        }
Beispiel #12
0
        /// <summary>Splits the document basing on the given size.</summary>
        /// <param name="size"><strong>Preferred</strong> size for splitting.</param>
        /// <returns>
        /// The documents which the source document was split into.
        /// Be warned that these documents are not closed.
        /// </returns>
        public virtual IList <PdfDocument> SplitBySize(long size)
        {
            IList <PageRange> splitRanges = new List <PageRange>();
            int currentPage = 1;
            int numOfPages  = pdfDocument.GetNumberOfPages();

            while (currentPage <= numOfPages)
            {
                PageRange nextRange = GetNextRange(currentPage, numOfPages, size);
                splitRanges.Add(nextRange);
                IList <int> allPages = nextRange.GetQualifyingPageNums(numOfPages);
                currentPage = (int)allPages[allPages.Count - 1] + 1;
            }
            return(ExtractPageRanges(splitRanges));
        }
Beispiel #13
0
        public virtual void AddCustomEvenConstructor()
        {
            PageRange range = new PageRange("even");

            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(5), JavaUtil.ArraysAsList(2, 4));
        }
Beispiel #14
0
        public virtual void AddSinglesConstructor()
        {
            PageRange range = new PageRange("5, 1");

            NUnit.Framework.Assert.AreEqual(range.GetQualifyingPageNums(10), JavaUtil.ArraysAsList(5, 1));
        }
Beispiel #15
0
        public virtual void AddIncorrectConstructor()
        {
            PageRange range = new PageRange("");

            NUnit.Framework.Assert.AreEqual(new List <Object>(), range.GetQualifyingPageNums(0));
        }
Beispiel #16
0
        public virtual void AddCustomAfterConstructor()
        {
            PageRange range = new PageRange("3-");

            NUnit.Framework.Assert.AreEqual(JavaUtil.ArraysAsList(3, 4, 5), range.GetQualifyingPageNums(5));
        }