private PDFSize CalculateAppropriateImageSize(PDFImageData imgdata, PDFRect bounds) { //Find the dimension that makes sure the bounds are fully covered double scale = (bounds.Width.PointsValue / imgdata.DisplayWidth.PointsValue); double resultHeight = imgdata.DisplayHeight.PointsValue * scale; if (resultHeight < bounds.Height) { scale = bounds.Height.PointsValue / imgdata.DisplayHeight.PointsValue; } PDFUnit imgw = imgdata.DisplayWidth.PointsValue * scale; PDFUnit imgh = imgdata.DisplayHeight.PointsValue * scale; if (imgw > bounds.Width) { this.XPostion = -((imgw.PointsValue - bounds.Width.PointsValue) / 2.0); } if (imgh > bounds.Height) { this.YPostion = -((imgh.PointsValue - bounds.Height.PointsValue) / 2.0); } this.XStep = imgw; this.YStep = imgh; return(new PDFSize(imgw, imgh)); }
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); }
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); }
public override bool SetUpGraphics(PDFGraphics graphics, PDFRect bounds) { bool result = base.SetUpGraphics(graphics, bounds); if (this.IsSet(SetValues.Color)) { graphics.SetStrokeColor(Color); } return(result); }
private void ReleaseTextRenderOptions(PDFTextRenderOptions options, PDFRect bounds) { if (options.FillBrush != null) { options.FillBrush.ReleaseGraphics(this, bounds); } if (options.Stroke != null) { options.Stroke.ReleaseGraphics(this, bounds); } }
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); }
/// <summary> /// Creates a new empty graphics path, ready to start adding operations to. /// </summary> protected PDFGraphicsPath(PDFObjectType type) : base(type) { Path p = new Path(); _paths = new List <Path>(); _paths.Add(p); _stack = new Stack <Path>(); _stack.Push(p); _bounds = PDFRect.Empty; }
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); } }
public void DrawRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height) { if (pen == null) { throw new ArgumentNullException("pen"); } this.SaveGraphicsState(); PDFRect rect = new PDFRect(x, y, width, height); pen.SetUpGraphics(this, rect); this.RenderRectangle(x, y, width, height); this.RenderStrokePathOp(); pen.ReleaseGraphics(this, rect); this.RestoreGraphicsState(); }
public void DrawRoundRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides, PDFUnit cornerRadius) { if (pen == null) { throw new ArgumentNullException("pen"); } PDFRect bounds = new PDFRect(x, y, width, height); this.SaveGraphicsState(); pen.SetUpGraphics(this, bounds); this.DoOutputRoundRectangleWithSidesPath(x, y, width, height, cornerRadius, sides); this.RenderStrokePathOp(); pen.ReleaseGraphics(this, bounds); this.RestoreGraphicsState(); }
public TextRenderMode SetTextRenderOptions(PDFTextRenderOptions options, PDFRect bounds) { TextRenderMode mode = TextRenderMode.NoOp; if (options == null) { throw new ArgumentNullException("options"); } if (options.FillBrush != null) { mode = TextRenderMode.Fill; options.FillBrush.SetUpGraphics(this, bounds); } if (options.Stroke != null) { if (mode == TextRenderMode.Fill) { mode = TextRenderMode.FillAndStroke; } else { mode = TextRenderMode.Stroke; } options.Stroke.SetUpGraphics(this, bounds); } if (options.Font != null) { this.SetCurrentFont(options.Font); } if (options.TextDirection.HasValue) { this.TextDirection = options.TextDirection.Value; } else { this.TextDirection = Scryber.TextDirection.LTR; } SetTextLeading(options); SetTextSpacing(options); SetTextRenderMode(mode); return(mode); }
public PDFRect TransformBounds(PDFRect bounds, TransformationOrigin origin) { PDFUnit xoffset = 0; PDFUnit yoffset = 0; switch (origin) { case TransformationOrigin.BottomLeft: //Do nothing - this is the default break; case TransformationOrigin.TopLeft: yoffset = (bounds.Y + bounds.Height); break; case TransformationOrigin.TopRight: xoffset = (bounds.X + bounds.Width); yoffset = (bounds.Y + bounds.Height); break; case TransformationOrigin.BottomRight: xoffset = (bounds.X + bounds.Width); break; case TransformationOrigin.CenterMiddle: xoffset = (bounds.X + (bounds.Width / 2)); yoffset = (bounds.Y + (bounds.Height / 2)); break; case TransformationOrigin.Origin: break; default: break; } bounds.X -= xoffset; bounds.Y -= yoffset; PDFRect transformed = TransformBounds(bounds); transformed.X += xoffset; transformed.Y += yoffset; return(transformed); }
public void DrawElipse(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height) { if (pen == null) { throw new ArgumentNullException("pen"); } PDFRect bounds = new PDFRect(x, y, width, height); this.SaveGraphicsState(); pen.SetUpGraphics(this, bounds); OutputElipsePoints(x, y, width, height); this.RenderCloseStrokePathOp(); pen.ReleaseGraphics(this, bounds); this.RestoreGraphicsState(); }
public void FillElipse(PDFBrush brush, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height) { if (brush == null) { throw new ArgumentNullException("brush"); } PDFRect bounds = new PDFRect(x, y, width, height); this.SaveGraphicsState(); brush.SetUpGraphics(this, bounds); OutputElipsePoints(x, y, width, height); this.RenderFillPathOp(); brush.ReleaseGraphics(this, bounds); this.RestoreGraphicsState(); }
private void OutputPath(PDFBrush brush, PDFPen pen, PDFPoint location, PDFGraphicsPath path) { PDFRect bounds = new PDFRect(path.Bounds.X + location.X, path.Bounds.Y + location.Y, path.Bounds.Width, path.Bounds.Height); if (null != brush) { brush.SetUpGraphics(this, bounds); } if (null != pen) { pen.SetUpGraphics(this, bounds); } PDFPoint cursor = PDFPoint.Empty; foreach (Path p in path.SubPaths) { RenderPathData(location, p, ref cursor); } if (null != brush && null != pen) { this.RenderFillAndStrokePathOp(path.Mode == GraphicFillMode.EvenOdd); } else if (null != brush) { this.RenderFillPathOp(path.Mode == GraphicFillMode.EvenOdd); } else if (null != pen) { this.RenderStrokePathOp(); } if (null != brush) { brush.ReleaseGraphics(this, bounds); } if (null != pen) { pen.ReleaseGraphics(this, bounds); } }
/// <summary> /// Internal method to render the grid /// </summary> protected virtual void DoRenderGrid(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, PDFUnit spacing) { this.Writer.WriteOpCodeS(PDFOpCode.SaveState); PDFRect bounds = new PDFRect(x, y, width, height); pen.SetUpGraphics(this, bounds); //Draw the vertical lines OutputVerticalLines(x.RealValue, y.RealValue, width.RealValue, height.RealValue, spacing.RealValue); //Draw the horizontal Lines OutputHorizontalLines(x.RealValue, y.RealValue, width.RealValue, height.RealValue, spacing.RealValue); pen.ReleaseGraphics(this, bounds); this.Writer.WriteOpCodeS(PDFOpCode.RestoreState); }
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); } }
public void FillRoundRectangle(PDFBrush brush, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides, PDFUnit cornerRadius) { if (brush == null) { throw new ArgumentNullException("brush"); } if (null != brush.UnderBrush) { this.FillRoundRectangle(brush.UnderBrush, x, y, width, height, sides, cornerRadius); } PDFRect bounds = new PDFRect(x, y, width, height); this.SaveGraphicsState(); brush.SetUpGraphics(this, bounds); this.DoOutputRoundRectangleWithSidesFill(x, y, width, height, cornerRadius, sides); this.RenderFillPathOp(); brush.ReleaseGraphics(this, bounds); this.RestoreGraphicsState(); }
public void FillRoundRectangle(PDFBrush brush, PDFRect rect, PDFUnit cornerRadius) { if (brush == null) { throw new ArgumentNullException("brush"); } if (null != brush.UnderBrush) { this.FillRoundRectangle(brush.UnderBrush, rect, cornerRadius); } this.SaveGraphicsState(); //PDFRect bounds = new PDFRect(x, y, width, height); brush.SetUpGraphics(this, rect); this.DoOutputRoundRectangle(rect.X, rect.Y, rect.Width, rect.Height, cornerRadius); this.RenderFillPathOp(); brush.ReleaseGraphics(this, rect); this.RestoreGraphicsState(); }
public PDFRect TransformBounds(PDFRect bounds) { if (this.IsIdentity) { return(bounds); } float width = (float)bounds.Width.PointsValue; float height = (float)bounds.Height.PointsValue; System.Drawing.PointF[] all = new System.Drawing.PointF[4]; all[0] = new System.Drawing.PointF((float)bounds.X.PointsValue, (float)bounds.Y.PointsValue); all[1] = new System.Drawing.PointF((float)bounds.X.PointsValue, (float)(bounds.Y.PointsValue + bounds.Height.PointsValue)); all[2] = new System.Drawing.PointF((float)(bounds.X.PointsValue + bounds.Width.PointsValue), (float)(bounds.Y.PointsValue + bounds.Height.PointsValue)); all[3] = new System.Drawing.PointF((float)(bounds.X.PointsValue + bounds.Width.PointsValue), (float)bounds.Y.PointsValue); this._matrix.TransformPoints(all); double maxX = all[0].X; double minX = all[0].X; double maxY = all[0].Y; double minY = all[0].Y; for (int i = 1; i < 4; i++) { maxX = Math.Max(maxX, all[i].X); minX = Math.Min(minX, all[i].X); maxY = Math.Max(maxY, all[i].Y); minY = Math.Min(minY, all[i].Y); } return(new PDFRect(minX, minY, maxX - minX, maxY - minY)); }
public void FillRectangle(PDFBrush brush, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height) { if (brush == null) { throw new ArgumentNullException("brush"); } if (null != brush.UnderBrush) { FillRectangle(brush.UnderBrush, x, y, width, height); } this.SaveGraphicsState(); PDFRect bounds = new PDFRect(x, y, width, height); brush.SetUpGraphics(this, bounds); this.RenderRectangle(x, y, width, height); this.RenderFillPathOp(); brush.ReleaseGraphics(this, bounds); this.RestoreGraphicsState(); }
public override void ReleaseGraphics(PDFGraphics g, PDFRect bounds) { }
public void DrawRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides) { if (pen == null) { throw new ArgumentNullException("pen"); } PDFRect rect = new PDFRect(x, y, width, height); this.SaveGraphicsState(); pen.SetUpGraphics(this, rect); //check to see if we are outputting all sides if (sides == (Sides.Top | Sides.Right | Sides.Left | Sides.Bottom)) { this.RenderRectangle(x, y, width, height); } else { bool recalc = true; //flag to identifiy if the last op moved the cursor to the next correct position if ((sides & Sides.Top) > 0) { this.RenderLine(x, y, x + width, y); recalc = false; } else { recalc = true; } if ((sides & Sides.Right) > 0) { if (recalc == false) { this.RenderContinuationLine(x + width, y + height); } else { this.RenderLine(x + width, y, x + width, y + height); } recalc = false; } else { recalc = true; } if ((sides & Sides.Bottom) > 0) { if (recalc == false) { this.RenderContinuationLine(x, y + height); } else { this.RenderLine(x + width, y + height, x, y + height); } recalc = false; } else { recalc = true; } if ((sides & Sides.Left) > 0) { if (recalc == false) { this.RenderContinuationLine(x, y); } else { this.RenderLine(x, y + height, x, y); } } } this.RenderStrokePathOp(); pen.ReleaseGraphics(this, rect); this.RestoreGraphicsState(); }
public void FillRectangle(PDFBrush brush, PDFRect rect) { this.FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height); }
public void DrawRectangle(PDFPen pen, PDFRect rect, Sides sides) { this.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height, sides); }
public void FillRoundRectangle(PDFBrush brush, PDFRect rect, Sides sides, PDFUnit cornerRadius) { this.FillRoundRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height, sides, cornerRadius); }
public void DrawRectangle(PDFPen pen, PDFRect rect) { this.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); }
public void DrawRoundRectangle(PDFPen pen, PDFRect rect, Sides sides, PDFUnit cornerRadius) { this.DrawRoundRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height, sides, cornerRadius); }
public void FillRoundRectangle(PDFBrush brush, PDFPoint pos, PDFSize size, PDFUnit cornerRadius) { PDFRect r = new PDFRect(pos, size); this.FillRoundRectangle(brush, r, cornerRadius); }
public void FillRoundRectangle(PDFBrush brush, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, PDFUnit cornerRadius) { PDFRect rect = new PDFRect(x, y, width, height); this.FillRoundRectangle(brush, rect, cornerRadius); }