Ejemplo n.º 1
0
        public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds)
        {
            if (this.IsSet(SetValues.Caps))
            {
                graphics.RenderLineCap(this.LineCaps);
            }
            if (this.IsSet(SetValues.Join))
            {
                graphics.RenderLineJoin(this.LineJoin);
            }
            if (this.IsSet(SetValues.Mitre))
            {
                graphics.RenderLineMitre(this.MitreLimit);
            }
            if (this.IsSet(SetValues.Width))
            {
                graphics.RenderLineWidth(this.Width);
            }
            if (this.Opacity.Value > 0.0)
            {
                graphics.SetStrokeOpacity(this.Opacity);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds)
        {
            bool result = base.SetUpGraphics(graphics, bounds);

            if (this.IsSet(SetValues.Dash))
            {
                graphics.RenderLineDash(this.Dash);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds)
        {
            bool result = base.SetUpGraphics(graphics, bounds);

            if (this.IsSet(SetValues.Color))
            {
                graphics.SetStrokeColor(Color);
            }
            return(result);
        }
        protected PDFRect ConvertToPageRect(PDFGraphics graphics, PDFRect bounds)
        {
            PDFRect pgRect = PDFRect.Empty;

            pgRect.X      = new PDFUnit(graphics.GetXPosition(bounds.X).Value);
            pgRect.Y      = new PDFUnit(graphics.GetYPosition(bounds.Y).Value);
            pgRect.Width  = new PDFUnit(graphics.GetXOffset(bounds.Width).Value);
            pgRect.Height = new PDFUnit(graphics.GetYOffset(bounds.Height).Value);

            return(pgRect);
        }
Ejemplo n.º 5
0
        public static PDFGraphics Create(PDFWriter writer, bool ownswriter, IPDFResourceContainer rsrc, DrawingOrigin origin, PDFSize size, PDFContextBase context)
        {
            if (origin == DrawingOrigin.BottomLeft)
            {
                throw new ArgumentException(Errors.GraphicsOnlySupportsTopDownDrawing, "origin");
            }

            PDFGraphics g = new PDFGraphics(writer, size, rsrc);

            g.OwnsWriter = ownswriter;
            g.Context    = context;
            return(g);
        }
Ejemplo n.º 6
0
 public override bool SetUpGraphics(PDFGraphics g, PDFRect bounds)
 {
     g.SetFillOpacity(this.Opacity);
     if (this.Color != null && this.Color.IsEmpty == false)
     {
         g.SetFillColor(this.Color);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
        public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds)
        {
            var doc = graphics.Container.Document;
            var id  = doc.GetIncrementID(PDFObjectTypes.Pattern);

            bounds = ConvertToPageRect(graphics, bounds);

            var linear = this.GetLinearShadingPattern(graphics, id, this._descriptor, bounds);

            if (null != linear)
            {
                var name = graphics.Container.Register(linear);
                graphics.SetFillPattern(name);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
 public override void ReleaseGraphics(PDFGraphics g, PDFRect bounds)
 {
 }
Ejemplo n.º 9
0
 public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds)
 {
     graphics.SetCurrentFont(this);
     return(true);
 }
        public PDFResource GetRadialShadingPattern(PDFGraphics g, string key, PDFGradientRadialDescriptor descriptor, PDFRect bounds)
        {
            PDFRadialShadingPattern pattern = new PDFRadialShadingPattern(g.Container.Document, key, descriptor, bounds);

            return(pattern);
        }
Ejemplo n.º 11
0
        //
        // graphics adapters
        //

        public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds)
        {
            graphics.SetTransformationMatrix(this, true, true);
            return(true);
        }
Ejemplo n.º 12
0
 public abstract void ReleaseGraphics(PDFGraphics g, PDFRect bounds);
Ejemplo n.º 13
0
 public abstract bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds);
 public override void ReleaseGraphics(PDFGraphics g, PDFRect bounds)
 {
     g.ClearFillPattern();
 }
        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);
            }
        }
Ejemplo n.º 16
0
 public override bool SetUpGraphics(PDFGraphics g, PDFRect bounds)
 {
     return(false);
 }