コード例 #1
0
        /// <summary>
        /// Value-setting constructor.
        /// </summary>
        /// <param name="parent">The parent node of this page in the document page tree.</param>
        /// <param name="objectId">The indirect object ID of this page.</param>
        /// <param name="size">The paper size of this page.</param>
        /// <param name="orientation">The orientation of this page.</param>
        /// <param name="horizontalMarginProportion">The proportion of the page taken up by each of the left and right margins.</param>
        /// <param name="verticalMarginProportion">The proportion of the page taken up by each of the top and bottom margins.</param>
        /// <param name="generation">The object generation number.  Defaults to zero.  As we do not currently support rewriting existing documents, this should not be set.</param>
        public PdfPage(
            PdfPageTreeNode parent,
            int objectId,
            PhysicalPageSize size,
            PageOrientation orientation,
            double horizontalMarginProportion,
            double verticalMarginProportion,
            int generation = 0)
            : base(parent, objectId, generation)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            PageSize        = size;
            PageOrientation = orientation;

            UniSize pagePtSize = size.ToUniSize(orientation);

            TopMarginPosition     = pagePtSize.Height * verticalMarginProportion;
            BottomMarginPosition  = pagePtSize.Height - TopMarginPosition;
            LeftMarginPosition    = pagePtSize.Width * horizontalMarginProportion;
            RightMarginPosition   = pagePtSize.Width - LeftMarginPosition;
            PageAvailableWidth    = RightMarginPosition - LeftMarginPosition;
            CurrentVerticalCursor = TopMarginPosition;
            MediaBox = size.ToPdfRectangle(orientation);
        }
コード例 #2
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithOneParameter_ThrowsArgumentOutOfRangeExceptionWhenParameterIsEqualToSix()
        {
            PhysicalPageSize testParam0 = (PhysicalPageSize)6;

            testParam0.ToPdfRectangle();

            Assert.Fail();
        }
コード例 #3
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithOneParameter_ThrowsArgumentOutOfRangeExceptionWhenParameterIsLessThanZero()
        {
            PhysicalPageSize testParam0 = (PhysicalPageSize)(_rnd.Next(2048) * -1 - 1);

            testParam0.ToPdfRectangle();

            Assert.Fail();
        }
コード例 #4
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithTwoParameters_ThrowsArgumentOutOfRangeExceptionWhenFirstParameterIsGreaterThanSixAndSecondParameterEqualsArbitrary()
        {
            PhysicalPageSize testParam0 = (PhysicalPageSize)(6 + _rnd.Next(2048));
            PageOrientation  testParam1 = PageOrientation.Arbitrary;

            testParam0.ToPdfRectangle(testParam1);

            Assert.Fail();
        }
コード例 #5
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithTwoParameters_ThrowsArgumentOutOfRangeExceptionWhenFirstParameterIsEqualToSixAndSecondParameterEqualsLandscape()
        {
            PhysicalPageSize testParam0 = (PhysicalPageSize)6;
            PageOrientation  testParam1 = PageOrientation.Landscape;

            testParam0.ToPdfRectangle(testParam1);

            Assert.Fail();
        }
コード例 #6
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithTwoParameters_ThrowsArgumentOutOfRangeExceptionWhenFirstParameterIsLessThanZeroAndSecondParameterEqualsPortrait()
        {
            PhysicalPageSize testParam0 = (PhysicalPageSize)(_rnd.Next(2048) * -1 - 1);
            PageOrientation  testParam1 = PageOrientation.Portrait;

            testParam0.ToPdfRectangle(testParam1);

            Assert.Fail();
        }
コード例 #7
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithOneParameter_ReturnsCorrectValueWhenParameterEqualsA6()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A6;

            PdfRectangle testOutput = testParam0.ToPdfRectangle();

            Assert.AreEqual(_zero, testOutput[0]);
            Assert.AreEqual(_zero, testOutput[1]);
            Assert.AreEqual(new PdfReal(297), testOutput[2]);
            Assert.AreEqual(new PdfReal(419), testOutput[3]);
        }
コード例 #8
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithTwoParameters_ReturnsCorrectValueWhenFirstParameterEqualsA6AndSecondParameterEqualsArbitrary()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A6;
            PageOrientation  testParam1 = PageOrientation.Arbitrary;

            PdfRectangle testOutput = testParam0.ToPdfRectangle(testParam1);

            Assert.AreEqual(_zero, testOutput[0]);
            Assert.AreEqual(_zero, testOutput[1]);
            Assert.AreEqual(new PdfReal(297), testOutput[2]);
            Assert.AreEqual(new PdfReal(419), testOutput[3]);
        }
コード例 #9
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithTwoParameters_ReturnsCorrectValueWhenFirstParameterEqualsA4AndSecondParameterEqualsLandscape()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A4;
            PageOrientation  testParam1 = PageOrientation.Landscape;

            PdfRectangle testOutput = testParam0.ToPdfRectangle(testParam1);

            Assert.AreEqual(_zero, testOutput[0]);
            Assert.AreEqual(_zero, testOutput[1]);
            Assert.AreEqual(new PdfReal(595), testOutput[3]);
            Assert.AreEqual(new PdfReal(841), testOutput[2]);
        }
コード例 #10
0
        public void PhysicalPageSizeExtensionsClass_ToPdfRectangleMethodWithTwoParameters_ReturnsCorrectValueWhenFirstParameterEqualsA2AndSecondParameterEqualsPortrait()
        {
            PhysicalPageSize testParam0 = PhysicalPageSize.A2;
            PageOrientation  testParam1 = PageOrientation.Portrait;

            PdfRectangle testOutput = testParam0.ToPdfRectangle(testParam1);

            Assert.AreEqual(_zero, testOutput[0]);
            Assert.AreEqual(_zero, testOutput[1]);
            Assert.AreEqual(new PdfReal(1190), testOutput[2]);
            Assert.AreEqual(new PdfReal(1683), testOutput[3]);
        }