Example #1
0
 public PDFRect(PDFPoint location, PDFSize size)
 {
     this._x = location.X;
     this._y = location.Y;
     this._w = size.Width;
     this._h = size.Height;
 }
Example #2
0
 /// <summary>
 /// Increases the size of this rectagle by the specified width and height. Returning the resulting rectangle
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <returns></returns>
 public PDFRect Inflate(PDFSize size)
 {
     return(this.Inflate(size.Width, size.Height));
 }
 /// <summary>
 /// Renders an even grid based upon the size and space
 /// </summary>
 /// <param name="pen">The pen to use</param>
 /// <param name="location">The starting location for the grid</param>
 /// <param name="size">The total size of the grid</param>
 /// <param name="spacing">The spacing between gridlines</param>
 public void RenderGrid(PDFPen pen, PDFPoint location, PDFSize size, PDFUnit spacing)
 {
     this.RenderGrid(pen, location.X, location.Y, size.Width, size.Height, spacing);
 }
Example #4
0
 public void FillElipse(PDFBrush brush, PDFPoint pos, PDFSize size)
 {
     this.FillElipse(brush, pos.X, pos.Y, size.Width, size.Height);
 }
Example #5
0
        /// <summary>
        /// Override so that the radial pattern extends beyond the set size to the farthest corner.
        /// With the repeat at the distances
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        protected override List <PDFGradientFunctionBoundary> GetRepeatingBoundaries(PDFPoint offset, PDFSize size)
        {
            var items = base.GetRepeatingBoundaries(offset, size);

            if (this.Size != RadialSize.None && this.Size != RadialSize.FarthestCorner)
            {
                var height = Math.Abs(size.Height.PointsValue);
                var width  = size.Width.PointsValue;

                //calculate the centre and radii for the names side and farthest corner
                var      newItems       = new List <PDFGradientFunctionBoundary>(items.Count);
                PDFPoint centre         = PDFRadialShadingPattern.CacluateRadialCentre(this.XCentre, this.YCentre, height, width);
                var      radiusActual   = Math.Abs(PDFRadialShadingPattern.CalculateRadiusForSize(this.Size, height, width, centre.X.PointsValue, centre.Y.PointsValue));
                var      radiusRequired = Math.Abs(PDFRadialShadingPattern.CalculateRadiusForSize(RadialSize.FarthestCorner, height, width, centre.X.PointsValue, centre.Y.PointsValue));

                //all our boundaries will be adjusted for the factor so we extend out.
                var factor = radiusActual / radiusRequired;

                var start    = 0.0;
                var boundary = 0.0;
                var index    = 0;

                while (boundary < 1)
                {
                    var one = items[index];
                    boundary = (one.Bounds * factor) + start;
                    one      = new PDFGradientFunctionBoundary(boundary);
                    newItems.Add(one);

                    index++;

                    if (index >= items.Count)
                    {
                        index    = 0;
                        start    = boundary;
                        boundary = 0.0;
                    }
                }

                this.Size = RadialSize.FarthestCorner;
                items     = newItems;
            }

            return(items);
        }
Example #6
0
 public void DrawElipse(PDFPen pen, PDFPoint pos, PDFSize size)
 {
     this.DrawElipse(pen, pos.X, pos.Y, size.Width, size.Height);
 }
Example #7
0
 public void FillQuadrants(PDFBrush brush, PDFPoint pos, PDFSize size, Quadrants sides)
 {
     this.FillQuadrants(brush, pos.X, pos.Y, size.Width, size.Height, sides);
 }
Example #8
0
 public void DrawQuadrants(PDFPen pen, PDFPoint pos, PDFSize size, Quadrants sides)
 {
     this.DrawQuadrants(pen, pos.X, pos.Y, size.Width, size.Height, sides);
 }
        public override bool SetUpGraphics(PDFGraphics g, PDFRect bounds)
        {
            Scryber.Resources.PDFImageXObject imagex;

            string fullpath = _source; // g.Container.MapPath(_source); - Map Path is done in the document now
            //TODO: Add XStep, YStep etc.
            string resourcekey = GetImagePatternKey(fullpath);


            PDFResource rsrc = g.Container.Document.GetResource(PDFResource.PatternResourceType, resourcekey, false);

            if (null == rsrc)
            {
                //Create the image
                imagex = g.Container.Document.GetResource(Scryber.Resources.PDFResource.XObjectResourceType, fullpath, true) as PDFImageXObject;

                if (null == imagex)
                {
                    if (g.Context.Conformance == ParserConformanceMode.Lax)
                    {
                        g.Context.TraceLog.Add(TraceLevel.Error, "Drawing", "Could not set up the image brush as the graphic image was not found or returned for : " + fullpath);
                        return(false);
                    }
                    else
                    {
                        throw new PDFRenderException("Could not set up the image brush as the graphic image was not found or returned for : " + fullpath);
                    }
                }

                //The container of a pattern is the document as this is the scope
                PDFImageTilingPattern tile = new PDFImageTilingPattern(g.Container.Document, resourcekey, imagex);
                tile.Container  = g.Container;
                tile.Image      = imagex;
                tile.PaintType  = PatternPaintType.ColoredTile;
                tile.TilingType = PatternTilingType.NoDistortion;

                //Calculate the bounds of the pattern

                PDFUnit width;
                PDFUnit height;
                PDFSize imgsize = CalculateAppropriateImageSize(imagex.ImageData, bounds);
                width  = imgsize.Width;
                height = imgsize.Height;


                //Patterns are drawn from the bottom of the page so Y is the container height minus the vertical position and offset
                PDFUnit y = 0; // g.ContainerSize.Height - (bounds.Y);// g.ContainerSize.Height - (bounds.Y + height + this.YPostion);
                //X is simply the horizontal position plus offset
                PDFUnit x = 0; // bounds.X + this.XPostion;

                tile.ImageSize = imgsize;

                PDFSize step = new PDFSize();
                if (this.XStep == 0)
                {
                    step.Width = width;
                }
                else
                {
                    step.Width = this.XStep;
                }

                if (this.YStep == 0)
                {
                    step.Height = height;
                }
                else
                {
                    step.Height = this.YStep;
                }
                tile.Step = step;

                PDFPoint start = new PDFPoint(bounds.X + this.XPostion, bounds.Y + this.YPostion);

                if (g.Origin == DrawingOrigin.TopLeft)
                {
                    start.Y = g.ContainerSize.Height - start.Y;
                }
                tile.Start = start;

                PDFName name = g.Container.Register(tile);

                g.SetFillPattern(name);
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public PDFGraphicsPathData(PDFSize size) : base(PDFObjectTypes.GraphicsPathData)
 {
     this._size = size;
 }