示例#1
0
        public virtual void ApplyMinHeightForSpecificDimensionsCausingFloatPrecisionError()
        {
            float divHeight = 42.55f;
            Div   div       = new Div();

            div.SetHeight(UnitValue.CreatePointValue(divHeight));
            float occupiedHeight = 17.981995f;
            float leftHeight     = 24.567993f;

            NUnit.Framework.Assert.IsTrue(occupiedHeight + leftHeight < divHeight);
            BlockRenderer blockRenderer = (BlockRenderer)div.CreateRendererSubTree();

            blockRenderer.occupiedArea = new LayoutArea(1, new Rectangle(0, 267.9681f, 0, occupiedHeight));
            AbstractRenderer renderer = blockRenderer.ApplyMinHeight(OverflowPropertyValue.FIT, new Rectangle(0, 243.40012f
                                                                                                              , 0, leftHeight));

            NUnit.Framework.Assert.IsNull(renderer);
        }
        /// <summary>
        /// Calculates the bounding box of the content in the coordinate system of the pdf entity on which content is placed,
        /// e.g. document page or form xObject. This is particularly useful for the cases when element is nested in the rotated
        /// element.
        /// </summary>
        /// <returns>a <see cref="Rectangle"/> which is a bbox of the content not relative to the parent's layout area but rather to
        /// the some pdf entity coordinate system.</returns>
        protected Rectangle CalculateAbsolutePdfBBox()
        {
            Rectangle        contentBox       = GetOccupiedAreaBBox();
            IList <Point>    contentBoxPoints = RectangleToPointsList(contentBox);
            AbstractRenderer renderer         = this;

            while (renderer.parent != null)
            {
                if (renderer is BlockRenderer)
                {
                    float?angle = renderer.GetProperty <float?>(Property.ROTATION_ANGLE);
                    if (angle != null)
                    {
                        BlockRenderer   blockRenderer     = (BlockRenderer)renderer;
                        AffineTransform rotationTransform = blockRenderer.CreateRotationTransformInsideOccupiedArea();
                        TransformPoints(contentBoxPoints, rotationTransform);
                    }
                }

                renderer = (AbstractRenderer)renderer.parent;
            }

            return(CalculateBBox(contentBoxPoints));
        }