public void Ellipse(Vector1D x, Vector1D y, Vector1D width, Vector1D height) { cb.Ellipse( (float)x.Value(UnitsOfMeasure.Points), (float)y.Value(UnitsOfMeasure.Points), (float)(x + width).Value(UnitsOfMeasure.Points), (float)(y + height).Value(UnitsOfMeasure.Points)); }
// =========================================================================== public void Write(Stream stream) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 PdfContentByte canvas = writer.DirectContent; // draw squares CreateSquares(canvas, 50, 720, 80, 20); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase( "Methods MoveTo(), LineTo(), stroke(), closePathStroke(), Fill(), and closePathFill()" ), 50, 700, 0 ); // draw Bezier curves createBezierCurves(canvas, 70, 600, 80, 670, 140, 690, 160, 630, 160); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase("Different CurveTo() methods, followed by stroke()"), 50, 580, 0 ); // draw stars and circles CreateStarsAndCircles(canvas, 50, 470, 40, 20); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase( "Methods Fill(), eoFill(), NewPath(), FillStroke(), and EoFillStroke()" ), 50, 450, 0 ); // draw different shapes using convenience methods canvas.SaveState(); canvas.SetColorStroke(new GrayColor(0.2f)); canvas.SetColorFill(new GrayColor(0.9f)); canvas.Arc(50, 270, 150, 330, 45, 270); canvas.Ellipse(170, 270, 270, 330); canvas.Circle(320, 300, 30); canvas.RoundRectangle(370, 270, 80, 60, 20); canvas.FillStroke(); canvas.RestoreState(); Rectangle rect = new Rectangle(470, 270, 550, 330); rect.BorderWidthBottom = 10; rect.BorderColorBottom = new GrayColor(0f); rect.BorderWidthLeft = 4; rect.BorderColorLeft = new GrayColor(0.9f); rect.BackgroundColor = new GrayColor(0.4f); canvas.Rectangle(rect); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase("Convenience methods"), 50, 250, 0 ); } }
public void Ellipse(PdfContentByte content, Rectangle rect) { content.SaveState(); content.SetRGBColorFill(0x00, 0x00, 0xFF); content.Ellipse( rect.Left - 3f, rect.Bottom - 5f, rect.Right + 3f, rect.Top + 3f ); content.Fill(); content.RestoreState(); }
public override void OnGenericTag( PdfWriter writer, Document pdfDocument, Rectangle rect, String text) { PdfContentByte content = writer.DirectContentUnder, rect); content.SaveState(); content.SetRGBColorFill(0x00, 0x00, 0xFF); content.Ellipse( rect.Left - 3f, rect.Bottom - 5f, rect.Right + 3f, rect.Top + 3f ); content.Fill(); content.RestoreState(); }
public void DrawEllipse(EbReportField field, float printingTop) { var x1 = field.Left; var y1 = Report.Height - (printingTop + field.Top + field.Height); var x2 = field.Left + field.Width; var y2 = Report.Height - (printingTop + field.Top); cb.SetColorStroke(GetColor(field.BorderColor)); cb.SetColorFill(GetColor(field.BackColor)); cb.SetLineWidth(field.Border); cb.Ellipse(x1, y1, x2, y2); cb.FillStroke(); }
public override void OnGenericTag(PdfWriter writer, Document document, Rectangle rect, string text) { if (text.Equals("ellipse")) { PdfContentByte cb = writer.DirectContent; cb.SetRGBColorStroke(0xFF, 0x00, 0x00); cb.Ellipse(rect.Left, rect.Bottom - 5f, rect.Right, rect.Top); cb.Stroke(); cb.ResetRGBColorStroke(); } else if (text.Equals("box")) { PdfContentByte cb = writer.DirectContent; rect.BackgroundColor = new BaseColor(0xa5, 0x2a, 0x2a); cb.Rectangle(rect); } }
protected internal override void AddEllipse(float x, float y, float height, float width, StyleInfo si, string url) { if (si.BStyleTop != BorderStyleEnum.None) { switch (si.BStyleTop) { case BorderStyleEnum.Dashed: _contentByte.SetLineDash(new float[] { '3', '2' }, 0); break; case BorderStyleEnum.Dotted: _contentByte.SetLineDash(new float[] { '2' }, 0); break; case BorderStyleEnum.Solid: default: _contentByte.SetLineDash(new float[] { }, 0); break; } _contentByte.SetRgbColorStroke(si.BColorTop.R, si.BColorTop.G, si.BColorTop.B); } float RadiusX = (width / 2.0f); float RadiusY = (height / 2.0f); _contentByte.Ellipse(x, PageSize.yHeight - y, x + RadiusX, y + RadiusY); if (!si.BackgroundColor.IsEmpty) { _contentByte.SetRgbColorStrokeF(si.BackgroundColor.R, si.BackgroundColor.G, si.BackgroundColor.B); } if (si.BackgroundColor.IsEmpty) { _contentByte.ClosePathStroke(); } else { _contentByte.ClosePathFillStroke(); } }
/// <summary> /// Add ellipse /// </summary> private void addEllipse(float x, float y, float width, float height, StyleInfo styleInfo, string url) { if (styleInfo.BStyleTop != BorderStyleEnum.None) { switch (styleInfo.BStyleTop) { case BorderStyleEnum.Dashed: pdfContent.SetLineDash(new float[] { '3', '2' }, 0); break; case BorderStyleEnum.Dotted: pdfContent.SetLineDash(new float[] { '2' }, 0); break; case BorderStyleEnum.Solid: default: pdfContent.SetLineDash(new float[] { }, 0); break; } pdfContent.SetRGBColorStroke(styleInfo.BColorTop.R, styleInfo.BColorTop.G, styleInfo.BColorTop.B); } pdfContent.Ellipse(x, pageHeight - y, x + (width / 2.0f), y + (height / 2.0f)); if (!styleInfo.BackgroundColor.IsEmpty) { pdfContent.SetRGBColorStrokeF(styleInfo.BackgroundColor.R, styleInfo.BackgroundColor.G, styleInfo.BackgroundColor.B); } if (styleInfo.BackgroundColor.IsEmpty) { pdfContent.ClosePathStroke(); } else { pdfContent.ClosePathFillStroke(); } }
// --------------------------------------------------------------------------- public byte[] CreatePdf() { using (MemoryStream ms = new MemoryStream()) { // step 1 using (Document document = new Document(new Rectangle(850, 600))) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, ms); // step 3 document.Open(); // step 4 PdfContentByte canvas = writer.DirectContent; // add the clipped image Image img = Image.GetInstance( Path.Combine(Utility.ResourceImage, RESOURCE) ); float w = img.ScaledWidth; float h = img.ScaledHeight; canvas.Ellipse(1, 1, 848, 598); canvas.Clip(); canvas.NewPath(); canvas.AddImage(img, w, 0, 0, h, 0, -600); // Create a transparent PdfTemplate PdfTemplate t2 = writer.DirectContent.CreateTemplate(850, 600); PdfTransparencyGroup transGroup = new PdfTransparencyGroup(); transGroup.Put(PdfName.CS, PdfName.DEVICEGRAY); transGroup.Isolated = true; transGroup.Knockout = false; t2.Group = transGroup; // Add transparent ellipses to the template int gradationStep = 30; float[] gradationRatioList = new float[gradationStep]; for (int i = 0; i < gradationStep; i++) { /* * gotta love .NET, guess they forgot to copy java.lang.Math.toRadians */ double radians = (Math.PI / 180) * 90.0f / gradationStep * (i + 1); gradationRatioList[i] = 1 - (float)Math.Sin(radians); } for (int i = 1; i < gradationStep + 1; i++) { t2.SetLineWidth(5 * (gradationStep + 1 - i)); t2.SetGrayStroke(gradationRatioList[gradationStep - i]); t2.Ellipse(0, 0, 850, 600); t2.Stroke(); } // Create an image mask for the direct content PdfDictionary maskDict = new PdfDictionary(); maskDict.Put(PdfName.TYPE, PdfName.MASK); maskDict.Put(PdfName.S, new PdfName("Luminosity")); maskDict.Put(new PdfName("G"), t2.IndirectReference); PdfGState gState = new PdfGState(); gState.Put(PdfName.SMASK, maskDict); canvas.SetGState(gState); canvas.AddTemplate(t2, 0, 0); } return(ms.ToArray()); } }
/// <summary> /// 画图逻辑代码在重写方法CellLayout内 /// </summary> /// <param name="cell"></param> /// <param name="position"></param> /// <param name="canvases"></param> public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { //PdfContentByte cb = canvases[PdfPTable.LINECANVAS];//指向的同一个引用,导致冲突 PdfContentByte cb = canvases[PdfPTable.BACKGROUNDCANVAS]; PdfContentByte cbline = canvases[PdfPTable.LINECANVAS]; cbline.SaveState(); cb.SaveState(); //画笔粗细 cb.SetLineWidth(0.4f); cbline.SetLineWidth(0.2f); cbline.SetRGBColorStroke(0x00, 0x00, 0x00); //注意Rectangle的四条边基于坐标原点为左下角 float leftX = position.Left + marginLeft; float bottomY = position.Bottom + marginBottom; float righX = position.Right - marginRight; float topY = position.Top - marginTop; //x轴单位刻度值 float xScale = (righX - leftX) / (this.axis.xAxis.Scale * (this.axis.xAxis.ScaleCount + 2));//x轴前后各空出一格 float yScale; //画x轴 cb.MoveTo(leftX, bottomY); cb.LineTo(righX, bottomY); cb.Stroke(); //画x轴突出的刻度 float xAxisTextLineWidth = 3f; float xAxisTextSpaceAdjust = 1.5f; for (float x = 0; x <= this.axis.xAxis.Scale * (this.axis.xAxis.ScaleCount); x += this.axis.xAxis.Scale) { float xPoint = leftX + (xScale * (this.axis.xAxis.Scale + x));//前面空一格 cb.MoveTo(xPoint, bottomY); cb.LineTo(xPoint, bottomY + xAxisTextLineWidth); cb.Stroke(); //x轴文本 ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, new Phrase(string.Format("{0}", x), new Font(BF_Light, 6)), xPoint + xAxisTextSpaceAdjust, bottomY - 2 * xAxisTextLineWidth, 0); } //y轴突出的刻度长度 float yAxisTextLineWidth = 3f; float yAxisTextSpaceAdjust = 2f; //y轴间间隙 float yGab = 10f; //避免标杆竖线重合重复画线(包括同一y轴和不同y轴) List <int> cblineIndex = new List <int>(); //y轴可能有多条,SeriesNum表示y轴位置...-2,-1,0,1,2,3...(0表示标准y轴) foreach (var yAxis in this.axis.yAxises) { //画y轴时画笔颜色 //cb.SetRGBColorStroke(0x00, 0x00, 0x00); cb.SetColorStroke(yAxis.BaseColor); //y轴位置 float yAxisPosition = leftX; if (yAxis.SeriesNum <= 0) { yAxisPosition = leftX + yAxis.SeriesNum * yGab; yAxisTextLineWidth = 3f;//虽然初始化为3f,但缺少这句导致当先画右边的y轴时再画左边y轴时,导致左边y轴刻度方向相反 } else { yAxisPosition = righX + (yAxis.SeriesNum - 1) * yGab; yAxisTextLineWidth = -3.2f; } //y轴单位刻度值 yScale = (topY - bottomY) / (yAxis.Scale * (yAxis.ScaleCount)); //画y轴 cb.MoveTo(yAxisPosition, bottomY); cb.LineTo(yAxisPosition, topY); cb.Stroke(); //画y轴突出的刻度 for (float y = 0; y <= yAxis.Scale * (yAxis.ScaleCount); y += yAxis.Scale) { float yPoint = bottomY + (yScale * y); cb.MoveTo(yAxisPosition, yPoint); cb.LineTo(yAxisPosition + yAxisTextLineWidth, yPoint); cb.Stroke(); //y轴文本 ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, new Phrase(string.Format("{0}", y), new Font(BF_Light, 6)), yAxis.SeriesNum <= 0 ? yAxisPosition - yAxisTextLineWidth : yAxisPosition - 4 * yAxisTextLineWidth, yPoint - yAxisTextSpaceAdjust, 0);//yAxisPosition = (leftX)righX + ...,左边、右边刻度文本位置分别基于leftX、righX,因此+、-不同 } //画y轴基准线//目前只画左边一条y轴上的基准线 if (yAxis.SeriesNum == 0 && yAxis.MaxValue.HasValue) { cb.SetLineDash(2, 2, 0); cb.SetColorStroke(BaseColor.RED); cb.MoveTo(leftX, bottomY + yScale * yAxis.MaxValue.Value); cb.LineTo(righX, bottomY + yScale * yAxis.MaxValue.Value); cb.Stroke(); cb.SetLineDash(0); cb.SetColorStroke(yAxis.BaseColor); } if (yAxis.SeriesNum == 0 && yAxis.MinValue.HasValue) { cb.SetLineDash(2, 2, 0); cb.SetColorStroke(BaseColor.RED); cb.MoveTo(leftX, bottomY + yScale * yAxis.MinValue.Value); cb.LineTo(righX, bottomY + yScale * yAxis.MinValue.Value); cb.Stroke(); cb.SetLineDash(0); cb.SetColorStroke(yAxis.BaseColor); } //画y轴标题 ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, new Phrase(string.Format("{0}", yAxis.Title + yAxis.Unit), new Font(BF_Light, 5)), yAxis.SeriesNum <= 0 ? yAxisPosition - yAxisTextLineWidth * (-3) : yAxisPosition - 4 * yAxisTextLineWidth / 2, bottomY + yAxis.Scale * (yAxis.ScaleCount) * yScale + yAxisTextSpaceAdjust * 2, 0); //描点并连线 //多组数据公用y轴 //某一y轴的一系列曲线 List <Series> curYseries = this.series.Where(p => p.SeriesNum == yAxis.SeriesNum).ToList(); //避免标杆竖线重合重复画线(包括同一y轴和不同y轴) //List<int> cblineIndex = new List<int>(); //var maxValue = series.Max(p => p.data.ydata.Max(pp => pp)); //var minValue = series.Min(p => p.data.ydata.Max(pp => pp)); //画某一y轴的一系列曲线 foreach (var line in curYseries) { //画曲线时画笔颜色 //cb.SetRGBColorStroke(0xFF, 0x45, 0x00); cb.SetColorStroke(line.BaseColor); var xdata = line.data.xdata; var ydata = line.data.ydata; //某条曲线描点并连线 for (int xIndex = 0; xIndex < xdata.Count; xIndex++) { float value = ydata[xIndex]; float xPoint = leftX + (this.axis.xAxis.Scale + xdata[xIndex]) * xScale; float yPoint = bottomY + yScale * value; //画曲线 if (xIndex == 0) { cb.MoveTo(xPoint, yPoint); } else { cb.LineTo(xPoint, yPoint); } //描点并连线画曲线同时画竖线 //避免重复画竖线-- if (!cblineIndex.Contains(xIndex)) { //竖线文本 //List<object> remark = new List<object>(); //指定位置处画竖线 if (yAxis.MaxValue.HasValue && value > yAxis.MaxValue.Value || yAxis.MinValue.HasValue && value < yAxis.MinValue.Value) { //标记此位置已有竖线,不再重复画线 cblineIndex.Add(xIndex); //竖线 cbline.MoveTo(xPoint, topY); cbline.LineTo(xPoint, bottomY + 2 * xAxisTextLineWidth); cbline.Stroke(); //竖线文本 //remark.Add(series.Select(p=>new {title = p.Title,value = p.data.xdata[xIndex]})); //竖线文本数 int textNum = 1; //循环所有曲线(包括不同y轴上的)找到竖线与曲线交点值并在交点处画圆点 this.series.OrderByDescending(p => p.Title).ToList().ForEach(p => { var title = p.Title + ":"; //var alarmInfo = "";//若有多次越过标杆线则此处会重复概览的alarmInfo //竖线标题 ColumnText.ShowTextAligned(cbline, Element.ALIGN_RIGHT, new Phrase(string.Format("{0}", title), new Font(BF_Light, 3.8f)), xPoint - xAxisTextSpaceAdjust, topY + textNum * xAxisTextLineWidth * 2, 0); //竖线值及其竖线与曲线交点处画圆点 var valueColor = BaseColor.GREEN; float lineValue = p.data.ydata[xIndex]; //曲线对应的y轴 var yaxis = this.axis.yAxises.Where(pp => pp.SeriesNum == p.SeriesNum).FirstOrDefault(); //y轴单位刻度值 var yscale = (topY - bottomY) / (yaxis.Scale * (yaxis.ScaleCount)); //仅在超标曲线交点处画圆点 if (yaxis.MaxValue.HasValue && lineValue > yaxis.MaxValue.Value || yaxis.MinValue.HasValue && lineValue < yaxis.MinValue.Value) { //画交点圆点 cbline.Ellipse(xPoint - 1, bottomY + lineValue * yscale - 1, xPoint + 1, bottomY + lineValue * yscale + 1); cbline.SetColorStroke(BaseColor.RED); //画圆圈颜色 cbline.SetColorFill(BaseColor.RED); //圆圈填充颜色 //cbline.SetLineWidth(0.2f);//画圆圈粗度同竖线粗度 cbline.FillStroke(); } cbline.SetColorFill(BaseColor.BLACK); //恢复颜色//否则画字体颜色会受到影响 cbline.SetColorStroke(BaseColor.BLACK); //单纯设为黑色无效需同时SetColorFill //是否超标 if (yaxis.MaxValue.HasValue && lineValue > yaxis.MaxValue.Value) { valueColor = BaseColor.RED; //alarmInfo += p.Title + "过高/"; } if (yaxis.MinValue.HasValue && lineValue < yaxis.MinValue.Value) { valueColor = BaseColor.RED; //alarmInfo += p.Title + "过低/"; } //竖线值 //设置一段文字各部分颜色--各颜色文字分开,但坐标如何自适应;Element.ALIGN_RIGHT+Element.ALIGN_LEFT ColumnText.ShowTextAligned(cbline, Element.ALIGN_LEFT, new Phrase(string.Format("{0}", lineValue), new Font(BF_Light, 3.8f, Font.NORMAL, valueColor)), xPoint + xAxisTextSpaceAdjust, topY + textNum * xAxisTextLineWidth * 2, 0); textNum++; }); } } } //以当前颜色画曲线 cb.Stroke(); } //以当前颜色画曲线,但是此时颜色为最后一次设置的颜色,产生bug //cb.Stroke(); } cb.RestoreState(); cbline.RestoreState(); }
public void ToPDF(iTextSharp.text.pdf.PdfWriter w) { PdfContentByte cb = w.DirectContent; cb.SetLineWidth((float)Settings.Thickness); if (Settings.Fill != null) { cb.SetColorFill(Settings.Fill.ToPDFColor()); } if (Settings.Stroke != null) { cb.SetColorStroke(Settings.Stroke.ToPDFColor()); } if (Geometry.GetType() == typeof(Dyn.Arc)) { Dyn.Arc arc = Geometry as Dyn.Arc; cb.MoveTo(arc.StartPoint.X, arc.EndPoint.Y); cb.CurveTo(arc.PointAtParameter(0.5).X, arc.PointAtParameter(0.5).Y, arc.EndPoint.X, arc.EndPoint.Y); } else if (Geometry.GetType() == typeof(Dyn.Line)) { Dyn.Line line = Geometry as Dyn.Line; cb.MoveTo(line.StartPoint.X, line.StartPoint.Y); cb.LineTo(line.EndPoint.X, line.EndPoint.Y); } else if (Geometry.GetType() == typeof(Dyn.Circle)) { Dyn.Circle circle = Geometry as Dyn.Circle; cb.Circle(circle.CenterPoint.X, circle.CenterPoint.Y, circle.Radius); } else if (Geometry.GetType() == typeof(Dyn.Ellipse)) { Dyn.Ellipse ellipse = Geometry as Dyn.Ellipse; cb.Ellipse(ellipse.StartPoint.X, ellipse.StartPoint.Y, ellipse.EndPoint.X, ellipse.EndPoint.Y); } else if (Geometry.GetType() == typeof(Dyn.Rectangle)) { Dyn.Rectangle rect = Geometry as Dyn.Rectangle; cb.Rectangle(rect.Center().X, rect.Center().Y, rect.Width, rect.Height); } else if (Geometry.GetType() == typeof(Dyn.Polygon)) { Dyn.Polygon p = Geometry as Dyn.Polygon; foreach (var curve in p.Curves()) { CurveToPDF(curve, cb); } } else if (Geometry.GetType() == typeof(Dyn.PolyCurve)) { Dyn.PolyCurve pc = Geometry as Dyn.PolyCurve; foreach (var curve in pc.Curves()) { CurveToPDF(curve, cb); } } else if (Geometry.GetType() == typeof(Dyn.NurbsCurve)) { Dyn.NurbsCurve nc = Geometry as Dyn.NurbsCurve; foreach (var linearc in nc.ApproximateWithArcAndLineSegments()) { CurveToPDF(linearc, cb); } } else if (Geometry.GetType() == typeof(Dyn.Curve)) { Dyn.Curve curve = Geometry as Dyn.Curve; CurveToPDF(curve, cb); } else { throw new Exception(Properties.Resources.NotSupported); } if (Settings.Fill != null && Settings.Stroke != null) { cb.FillStroke(); } else { if (Settings.Stroke != null) { cb.Stroke(); } if (Settings.Fill != null) { cb.Fill(); } } }
/* Draw one note, do = 1. * content: Drawing content container. * left: Beginning position. * up: Beginning position. * number: Tone. * length: Length of the note, currently support 1, 0.75, 0.5, 0.25. */ private void DrawOneScore(PdfContentByte content, float left, float up, double number, double length = 1) { // TODO(allenxie): Deal with flag == false. up = PageSize.A4.Height - up; float position = up - 5 * lineSpace + ((float)number - 1) * lineSpace / 2; // Circle content.SetColorFill(BaseColor.BLACK); // content.Circle(left, position, scoreRadius); content.Ellipse(left - 4, position - 3, left + 4, position + 3); content.Fill(); // Vertical line (0.5 is for good-looking) if (number < 8) { content.MoveTo(left + scoreRadius + 0.5, position); content.LineTo(left + scoreRadius + 0.5, position + 3.5 * lineSpace); content.Stroke(); if (length == 0.5 || length == 0.75) { double left_start = left + scoreRadius + 0.5; double up_start = position + 3.5 * lineSpace - 0.5; content.MoveTo(left_start, up_start); content.CurveTo(left_start + 1, up_start - 4, left_start + 7, up_start - 7, left_start + 4, up_start - 12); content.Stroke(); if (length == 0.75) { double dot_position = (number % 2 == 0) ? position : position + 0.5 * lineSpace; content.Circle(left_start + 3, dot_position, 1); content.Fill(); } } if (length == 0.25) { double left_start = left + scoreRadius + 0.5; double up_start = position + 3.5 * lineSpace - 0.5; content.MoveTo(left_start, up_start); content.CurveTo(left_start + 1, up_start - 3, left_start + 6, up_start - 6, left_start + 3, up_start - 9); content.Stroke(); up_start = up_start - 4; content.MoveTo(left_start, up_start); content.CurveTo(left_start + 1, up_start - 3, left_start + 6, up_start - 6, left_start + 3, up_start - 9); content.Stroke(); } } else { content.MoveTo(left - scoreRadius - 0.5, position); content.LineTo(left - scoreRadius - 0.5, position - 3.5 * lineSpace); content.Stroke(); if (length == 0.5 || length == 0.75) { double left_start = left - scoreRadius - 0.5; double up_start = position - 3.5 * lineSpace + 0.5; content.MoveTo(left_start, up_start); content.CurveTo(left_start + 1, up_start + 4, left_start + 7, up_start + 7, left_start + 4, up_start + 12); content.Stroke(); if (length == 0.75) { double dot_position = (number % 2 == 0) ? position : position + 0.5 * lineSpace; content.Circle(left_start + 8, dot_position, 1); content.Fill(); } } if (length == 0.25) { double left_start = left - scoreRadius - 0.5; double up_start = position - 3.5 * lineSpace + 0.5; content.MoveTo(left_start, up_start); content.CurveTo(left_start + 1, up_start + 3, left_start + 6, up_start + 6, left_start + 3, up_start + 9); content.Stroke(); up_start = up_start + 4; content.MoveTo(left_start, up_start); content.CurveTo(left_start + 1, up_start + 3, left_start + 6, up_start + 6, left_start + 3, up_start + 9); content.Stroke(); } } // If need addition lateral line if (number < 2 && ((int)number % 2 == 0)) { content.MoveTo(left - scoreRadius * 2, position + scoreRadius); content.LineTo(left + scoreRadius * 2, position + scoreRadius); content.Stroke(); } else if (number < 2 && ((int)number % 2 != 0)) { content.MoveTo(left - scoreRadius * 2, position); content.LineTo(left + scoreRadius * 2, position); content.Stroke(); } else if (number > 12 && ((int)number % 2 == 0)) { content.MoveTo(left - scoreRadius * 2, position - scoreRadius); content.LineTo(left + scoreRadius * 2, position - scoreRadius); content.Stroke(); } else if (number > 12 && ((int)number % 2 != 0)) { content.MoveTo(left - scoreRadius * 2, position); content.LineTo(left + scoreRadius * 2, position); content.Stroke(); } }
// --------------------------------------------------------------------------- /** * Creates a PDF document. */ public byte[] CreatePdf() { using (MemoryStream ms = new MemoryStream()) { // step 1 using (Document document = new Document()) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, ms); // step 3 document.Open(); // step 4 PdfContentByte canvas = writer.DirectContent; PdfPatternPainter square = canvas.CreatePattern(15, 15); square.SetColorFill(new BaseColor(0xFF, 0xFF, 0x00)); square.SetColorStroke(new BaseColor(0xFF, 0x00, 0x00)); square.Rectangle(5, 5, 5, 5); square.FillStroke(); PdfPatternPainter ellipse = canvas.CreatePattern(15, 10, 20, 25); ellipse.SetColorFill(new BaseColor(0xFF, 0xFF, 0x00)); ellipse.SetColorStroke(new BaseColor(0xFF, 0x00, 0x00)); ellipse.Ellipse(2f, 2f, 13f, 8f); ellipse.FillStroke(); PdfPatternPainter circle = canvas.CreatePattern(15, 15, 10, 20, BaseColor.BLUE); circle.Circle(7.5f, 7.5f, 2.5f); circle.Fill(); PdfPatternPainter line = canvas.CreatePattern(5, 10, null); line.SetLineWidth(1); line.MoveTo(3, -1); line.LineTo(3, 11); line.Stroke(); Image img = Image.GetInstance(RESOURCE); img.ScaleAbsolute(20, 20); img.SetAbsolutePosition(0, 0); PdfPatternPainter img_pattern = canvas.CreatePattern(20, 20, 20, 20); img_pattern.AddImage(img); img_pattern.SetPatternMatrix(-0.5f, 0f, 0f, 0.5f, 0f, 0f); ColorRectangle(canvas, new PatternColor(square), 36, 696, 126, 126); ColorRectangle(canvas, new PatternColor(ellipse), 180, 696, 126, 126); ColorRectangle(canvas, new PatternColor(circle), 324, 696, 126, 126); ColorRectangle(canvas, new PatternColor(line), 36, 552, 126, 126); ColorRectangle(canvas, new PatternColor(img_pattern), 36, 408, 126, 126); canvas.SetPatternFill(line, BaseColor.RED); canvas.Ellipse(180, 552, 306, 678); canvas.FillStroke(); canvas.SetPatternFill(circle, BaseColor.GREEN); canvas.Ellipse(324, 552, 450, 678); canvas.FillStroke(); canvas.SetPatternFill(img_pattern); canvas.Ellipse(180, 408, 450, 534); canvas.FillStroke(); } return(ms.ToArray()); } }
// SVG has the center point of the ellipse and the radius for x and y, // iText needs the describing rectangle protected override void Draw(PdfContentByte cb) { cb.Ellipse(x - rx, y + ry, x + rx, y - ry); }
public void Verify_PathConstructionAndPainting_CanBeCreated() { var pdfFilePath = TestUtils.GetOutputFileName(); var stream = new FileStream(pdfFilePath, FileMode.Create); // step 1 var document = new Document(); // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.AddAuthor(TestUtils.Author); document.Open(); // step 4 PdfContentByte canvas = writer.DirectContent; // draw squares createSquares(canvas, 50, 720, 80, 20); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase( "Methods MoveTo(), LineTo(), stroke(), closePathStroke(), Fill(), and closePathFill()" ), 50, 700, 0 ); // draw Bezier curves createBezierCurves(canvas, 70, 600, 80, 670, 140, 690, 160, 630, 160); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase("Different CurveTo() methods, followed by stroke()"), 50, 580, 0 ); // draw stars and circles createStarsAndCircles(canvas, 50, 470, 40, 20); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase( "Methods Fill(), eoFill(), NewPath(), FillStroke(), and EoFillStroke()" ), 50, 450, 0 ); // draw different shapes using convenience methods canvas.SaveState(); canvas.SetColorStroke(new GrayColor(0.2f)); canvas.SetColorFill(new GrayColor(0.9f)); canvas.Arc(50, 270, 150, 330, 45, 270); canvas.Ellipse(170, 270, 270, 330); canvas.Circle(320, 300, 30); canvas.RoundRectangle(370, 270, 80, 60, 20); canvas.FillStroke(); canvas.RestoreState(); Rectangle rect = new Rectangle(470, 270, 550, 330) { BorderWidthBottom = 10, BorderColorBottom = new GrayColor(0f), BorderWidthLeft = 4, BorderColorLeft = new GrayColor(0.9f), BackgroundColor = new GrayColor(0.4f) }; canvas.Rectangle(rect); ColumnText.ShowTextAligned( canvas, Element.ALIGN_LEFT, new Phrase("Convenience methods"), 50, 250, 0 ); document.Close(); stream.Dispose(); TestUtils.VerifyPdfFileIsReadable(pdfFilePath); }
public void GuardarFiguras(string nombrePDF, int page) { Console.WriteLine("Entro a funcion guardar figuras nombrepdf " + nombrePDF); string oldFile = nombrePDF; string newFile = "C:\\Users\\Denisse\\Desktop\\EDDIE-Augmented-Reading-master\\AugmentedReadingApp\\bin\\x86\\Debug\\temporal.pdf"; PdfReader reader = new PdfReader(oldFile); var pageSize = reader.GetPageSize(1); Console.WriteLine("Tamano de pagina PDF " + pageSize); PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Append)); PdfContentByte contentunder = stamper.GetUnderContent(1); //int rot; //rot = reader.GetPageRotation(1); //PdfDictionary pageDict; //pageDict = reader.GetPageN(1); //pageDict.Put(PdfName.ROTATE, new PdfNumber(rot + 90)); float incremento = 130; foreach (var item in rect) { //float center1 = item.X+(item.X+item.Width)/2; //float center2 = item.Y + (item.Y + item.Height) / 2; //RotatedRect aux = new RotatedRect(new PointF(item.X, item.Y), item.Size, 180); //PointF[] puntos = aux.GetVertices(); //float puntoX = puntos[0].X; //float puntoY = puntos[0].Y; //float tamanoH = item.Size.Height; //float tamanoW = item.Size.Width; float porcentaje = (item.Y * 100 / 640); double nuevoPtoY = (porcentaje * (841)) / 100; double proporcion = nuevoPtoY / item.Y; if (porcentaje < 50) { incremento = 0; } else if (porcentaje > 50 && porcentaje < 80) { incremento = 70; } else { incremento = 100; } contentunder.SetColorStroke(BaseColor.YELLOW); ////Antigua coordenada contentunder.Rectangle(item.X - 50, (841 * 0.85) - (nuevoPtoY * proporcion)+incremento, item.Width * 1.3, item.Height * proporcion); ////nueva coordenada double propX = ((item.X * 100) / 640); double ptoX2 = ((propX * 792) / 100); double propY = ((item.Y * 100) / 480); double ptoY2 = ((propY * 612) / 100); double propArea = 1.58; double propW = ((item.Width) * 100) / 640; double ptoW2 = ((propW * 792) / 100); double propH = ((item.Height * 100) / 480); double ptoH2 = ((propH * 612) / 100); contentunder.Rectangle(ptoX2 + 30, (612 - ptoY2 - (ptoH2 - 30)), ptoW2 - 30, ptoH2 - 30); //contentunder.Rectangle(puntoX, puntoY, tamanoW, tamanoH); contentunder.Stroke(); } //Sincronizar circulos foreach (var circle in circleList) { /*double x = circle.Center.X; * double y = circle.Center.Y; * double r = circle.Radius; * double porcentaje = (y * 100 / 640); * double nuevoPtoY = (porcentaje * (841*0.9)) / 100; * double proporcion = nuevoPtoY / y; * * // Setting color to the circle * contentunder.SetColorStroke(BaseColor.MAGENTA); * // creating a circle * contentunder.Circle(x, (841*0.9)-(nuevoPtoY), r*proporcion);*/ double propX = ((circle.Center.X * 100) / 640); double ptoX2 = ((propX * 792) / 100); double propY = ((circle.Center.Y * 100) / 480); double ptoY2 = ((propY * 612) / 100); double r = circle.Radius; // Setting color to the circle contentunder.SetColorStroke(BaseColor.MAGENTA); // creating a circle contentunder.Circle(ptoX2, 612 - ptoY2 - r, r * 1.58); // Filling the circ //canvas.Fill(); contentunder.Stroke(); } //Sincronizar elipses y circulos foreach (var ellipse in ellipseList) { System.Drawing.Rectangle rr = ellipse.RotatedRect.MinAreaRect(); double propLeft = ((rr.Left * 100) / 640); double ptoLeft2 = ((propLeft * 792) / 100); double propRight = ((rr.Right * 100) / 640); double ptoRight2 = ((propRight * 792) / 100); double propBottom = ((rr.Bottom * 100) / 480); double ptoBottom2 = ((propBottom * 612) / 100); double propTop = ((rr.Top * 100) / 480); double ptoTop2 = ((propTop * 612) / 100); contentunder.SetColorStroke(BaseColor.GREEN); contentunder.Ellipse(ptoLeft2, 612 - ptoBottom2, ptoRight2, 612 - ptoTop2); /*double porcentajeB = (rr.Bottom * 100 / 640); * double nuevoPtoB = (porcentajeB * (841)) / 100; * double proporcionB = nuevoPtoB / rr.Bottom; * * double porcentajeT = (rr.Top * 100 / 640); * double nuevoPtoT = (porcentajeT * (841)) / 100; * double proporcionT = nuevoPtoB / rr.Top; * * contentunder.SetColorStroke(BaseColor.GREEN); * contentunder.Ellipse(rr.Left - 50, (841 * 0.9) - (nuevoPtoB), (rr.Right * 1.1) - 80, (841 * 0.9) - (nuevoPtoT));*/ contentunder.Stroke(); } stamper.Close(); reader.Close(); File.Replace(@newFile, oldFile, @"backup.pdf.bac"); Console.WriteLine("Finalizado"); //File.Replace(@"temporal.pdf", @"ejemploOK.pdf", @"backup.pdf.bac"); // MessageBox.Show("Pdf modificado con exito, se ha guardado un backup de la versión anterior "); //axAcroPDF1.src = "C:\\Users\\Denisse\\Desktop\\prototipos\\Prototipo4-FigurasFisicoDigital\\Prototipo4-FigurasFisicoDigital\\bin\\Debug\\ejemploOK.pdf"; }
private static Boolean PrintShape(Shape shape, FrameworkElement relativeTo, PdfContentByte dc) { var noBorder = Helper.IsNullOrZero(shape.StrokeThickness) || Helper.IsTransparent(shape.Stroke); var noBackground = Helper.IsTransparent(shape.Fill); if (noBorder && noBackground) return true; dc.SaveState(); try { var clipRect = GetClipRectange(shape, relativeTo); if (clipRect != null) { dc.Rectangle(clipRect.Value.Left, clipRect.Value.Top - clipRect.Value.Height, clipRect.Value.Width, clipRect.Value.Height); dc.Clip(); dc.NewPath(); } dc.SetColorFill(GetBaseColor(shape.Fill)); dc.SetColorStroke(GetBaseColor(shape.Stroke)); dc.SetLineWidth(shape.StrokeThickness); if (shape.StrokeDashArray != null && shape.StrokeDashArray.Any()) dc.SetLineDash(shape.StrokeDashArray.Select(p => p * shape.StrokeThickness).ToArray(), 0); float left, top; if (!GetElementLocation(shape, relativeTo, out left, out top)) return false; var lineGeometry = shape.RenderedGeometry as LineGeometry; if (lineGeometry != null) { var startPoint = shape.RenderedGeometry.Transform.Transform(lineGeometry.StartPoint); var endPoint = shape.RenderedGeometry.Transform.Transform(lineGeometry.EndPoint); dc.MoveTo(left + startPoint.X, top - startPoint.Y); dc.LineTo(left + endPoint.X, top - endPoint.Y); } var rectangleGeometry = shape.RenderedGeometry as RectangleGeometry; if (rectangleGeometry != null) { if (!rectangleGeometry.Rect.IsNaNOrZeroOrEmpty()) { var bottomLeft = shape.RenderedGeometry.Transform.Transform(rectangleGeometry.Rect.BottomLeft); var widthHeight = shape.RenderedGeometry.Transform.Transform(new Point(rectangleGeometry.Rect.Width, rectangleGeometry.Rect.Height)); dc.Rectangle(left + bottomLeft.X, top - bottomLeft.Y, widthHeight.X, widthHeight.Y); } } var ellipseGeometry = shape.RenderedGeometry as EllipseGeometry; if (ellipseGeometry != null) { var center = shape.RenderedGeometry.Transform.Transform(ellipseGeometry.Center); center = new Point(left + center.X, top - center.Y); if (Helper.IsNullOrZero(ellipseGeometry.RadiusX) && Helper.IsNullOrZero(ellipseGeometry.RadiusY)) dc.Circle(center.X, center.Y, 0.01); else { var radius = shape.RenderedGeometry.Transform.Transform(new Point(ellipseGeometry.RadiusX, ellipseGeometry.RadiusY)); var x1 = (Int32)Math.Max(1, Math.Round(center.X - radius.X)); var y1 = (Int32)Math.Max(1, Math.Round(center.Y - radius.Y)); var x2 = (Int32)Math.Max(1, Math.Round(center.X + radius.X)); var y2 = (Int32)Math.Max(1, Math.Round(center.Y + radius.Y)); dc.Ellipse(x1, y1, x2, y2); } } var streamGeometry = shape.RenderedGeometry as StreamGeometry; if (streamGeometry != null) { var figures = GeometryDataParser.GetDataFigures(streamGeometry.ToString()); foreach (var figure in figures) { if (!figure.Draw(left, top, dc, shape.LayoutTransform)) break; } } var pathGrometry = shape.RenderedGeometry as PathGeometry; if (pathGrometry != null) { var pathFigure = pathGrometry.Figures.First(p => p != null); if (pathFigure != null) { var points = new List<Point>(); points.Add(shape.RenderedGeometry.Transform.Transform(pathFigure.StartPoint)); var lineSegments = pathFigure.Segments.OfType<LineSegment>(); if (lineSegments != null) points.AddRange(lineSegments.Select(p => shape.RenderedGeometry.Transform.Transform(p.Point))); var polyLineSegment = pathFigure.Segments.OfType<PolyLineSegment>().FirstOrDefault(); if (polyLineSegment != null) points.AddRange(polyLineSegment.Points.Select(p => shape.RenderedGeometry.Transform.Transform(p))); points = points.Select(p => new Point(left + p.X, top - p.Y)).ToList(); foreach (var point in points) { if (points.IndexOf(point) == 0) dc.MoveTo(point.X, point.Y); else dc.LineTo(point.X, point.Y); } } } if (!noBorder && !noBackground) dc.FillStroke(); else { if (!noBorder) dc.Stroke(); if (!noBackground) dc.Fill(); } return true; } catch (Exception ex) { ExceptionHandler.ThrowException(ex); return false; } finally { dc.RestoreState(); } }
private void button2_Click(object sender, EventArgs e) { string oldFile = "opcion2X.pdf"; string newFile = "temporal.pdf"; // string oldFile = textBox6.Text; //string newFile = "Code2.pdf"; /* PdfDocument pdfDoc = new PdfDocument(new PdfReader(oldFile), new PdfWriter(newFile)); * PdfCanvas canvas = new PdfCanvas(pdfDoc.GetFirstPage()); * iText.Kernel.Geom.Rectangle mediabox = pdfDoc.GetPage(1).GetMediaBox(); * double anchoPDF = mediabox.GetWidth(); * double altoPDF = mediabox.GetHeight();*/ //MessageBox.Show("Medidas PDF ancho: "+ anchoPDF + " y alto: "+ altoPDF); //Sincronizar rectangulos //float incremento = 130; //Bitmap bmp = new Bitmap(1000, 1000, PixelFormat.Format32bppArgb); /* MemoryStream ms = new MemoryStream(); * bmp.Save(ms, ImageFormat.Png); * byte[] bmpBytes = ms.ToArray(); * ImageData data = ImageDataFactory.Create( bmpBytes); * * * canvas.AddImage(data,100,500,false);*/ /* * foreach (var item in rect) * { * * * float porcentaje = (item.Y * 100 / 640); * double nuevoPtoY = (porcentaje * (841)) / 100; * double proporcion = nuevoPtoY / item.Y; * if (porcentaje < 50) * { * incremento = 0; * } * else if (porcentaje > 50 && porcentaje < 80) * { * incremento = 70; * } * else * { * incremento = 100; * } * * * //El x estaba con -50 * canvas.SetStrokeColor(new DeviceRgb(0, 0, 255)) * .SetLineWidth(2) * .Rectangle(item.X-80, (841*0.9)-(nuevoPtoY*proporcion), item.Width*1.3, item.Height*proporcion) * .Stroke(); * } */ //Sincronizar triangulos /*foreach (var triangle in triangleList) * { * canvas.SetStrokeColor(new DeviceRgb(0, 0, 255)); * PointF[] vertices = triangle.GetVertices(); * MessageBox.Show("estos son los vertices 0: " + vertices[0] + " 1: " +vertices[1] + " 2:" + vertices[2]); * double area = triangle.Area; * double h = (2 * area / (vertices[0].X - vertices[2].X)); * MessageBox.Show("esto es el area y esto el h "+area+ " " + h); * double x = (vertices[2].X+(vertices[0].X - vertices[2].X)); * double y = vertices[2].Y; * canvas.MoveTo(x, y); * canvas.LineTo(vertices[1].X, (vertices[1].Y+(h*2))); * canvas.LineTo((vertices[0].X-(vertices[0].X - vertices[2].X)), vertices[0].Y); * canvas.Stroke(); * }*/ //Sincronizar circulos /* foreach (var circle in circleList) * { * double x = circle.Center.X; * double y = circle.Center.Y; * double r = circle.Radius; * double porcentaje = (y * 100 / 640); * double nuevoPtoY = (porcentaje * (841*0.9)) / 100; * double proporcion = nuevoPtoY / y; * // Setting color to the circle * canvas.SetStrokeColor(new DeviceRgb(0, 255, 0)); * // creating a circle * canvas.Circle(x-50, (841*0.9)-(nuevoPtoY), r*proporcion); * * // Filling the circ * //canvas.Fill(); * canvas.Stroke(); * }*/ //Sincronizar elipses y circulos /* foreach (var ellipse in ellipseList) * { * System.Drawing.Rectangle rr = ellipse.RotatedRect.MinAreaRect(); * double porcentajeB = (rr.Bottom * 100 / 640); * double nuevoPtoB = (porcentajeB * (841)) / 100; * double proporcionB = nuevoPtoB / rr.Bottom; * * double porcentajeT = (rr.Top * 100 / 640); * double nuevoPtoT = (porcentajeT * (841)) / 100; * double proporcionT = nuevoPtoB / rr.Top; * * canvas.SetStrokeColor(new DeviceRgb(255, 0, 255)) * * .Ellipse( rr.Left-80, (841*0.9)-(nuevoPtoB), (rr.Right*1.1)-80, (841*0.9)-(nuevoPtoT)) * .Stroke(); * } * * * pdfDoc.Close(); */ PdfReader reader = new PdfReader(oldFile); var pageSize = reader.GetPageSize(1); Console.WriteLine("Tamano de pagina PDF " + pageSize); PdfStamper stamper = new PdfStamper(reader, new FileStream(newFile, FileMode.Append)); PdfContentByte contentunder = stamper.GetUnderContent(1); //int rot; //rot = reader.GetPageRotation(1); //PdfDictionary pageDict; //pageDict = reader.GetPageN(1); //pageDict.Put(PdfName.ROTATE, new PdfNumber(rot + 90)); float incremento = 130; foreach (var item in rect) { //float center1 = item.X+(item.X+item.Width)/2; //float center2 = item.Y + (item.Y + item.Height) / 2; //RotatedRect aux = new RotatedRect(new PointF(item.X, item.Y), item.Size, 180); //PointF[] puntos = aux.GetVertices(); //float puntoX = puntos[0].X; //float puntoY = puntos[0].Y; //float tamanoH = item.Size.Height; //float tamanoW = item.Size.Width; float porcentaje = (item.Y * 100 / 640); double nuevoPtoY = (porcentaje * (841)) / 100; double proporcion = nuevoPtoY / item.Y; if (porcentaje < 50) { incremento = 0; } else if (porcentaje > 50 && porcentaje < 80) { incremento = 70; } else { incremento = 100; } MessageBox.Show("Info rectangulo real : " + item.X + ", puntoY : " + item.Y + ", tamanoH : " + item.Height + ", tamanoW : " + item.Width); contentunder.SetColorStroke(BaseColor.YELLOW); ////Antigua coordenada contentunder.Rectangle(item.X - 50, (841 * 0.85) - (nuevoPtoY * proporcion)+incremento, item.Width * 1.3, item.Height * proporcion); ////nueva coordenada double propX = ((item.X * 100) / 640); double ptoX2 = ((propX * 792) / 100); double propY = ((item.Y * 100) / 480); double ptoY2 = ((propY * 612) / 100); double propArea = 1.58; double propW = ((item.Width) * 100) / 640; double ptoW2 = ((propW * 792) / 100); double propH = ((item.Height * 100) / 480); double ptoH2 = ((propH * 612) / 100); contentunder.Rectangle(ptoX2 + 30, (612 - ptoY2 - (ptoH2 - 30)), ptoW2 - 30, ptoH2 - 30); //contentunder.Rectangle(puntoX, puntoY, tamanoW, tamanoH); contentunder.Stroke(); } //Sincronizar circulos foreach (var circle in circleList) { /*double x = circle.Center.X; * double y = circle.Center.Y; * double r = circle.Radius; * double porcentaje = (y * 100 / 640); * double nuevoPtoY = (porcentaje * (841*0.9)) / 100; * double proporcion = nuevoPtoY / y; * * // Setting color to the circle * contentunder.SetColorStroke(BaseColor.MAGENTA); * // creating a circle * contentunder.Circle(x, (841*0.9)-(nuevoPtoY), r*proporcion);*/ double propX = ((circle.Center.X * 100) / 640); double ptoX2 = ((propX * 792) / 100); double propY = ((circle.Center.Y * 100) / 480); double ptoY2 = ((propY * 612) / 100); double r = circle.Radius; // Setting color to the circle contentunder.SetColorStroke(BaseColor.MAGENTA); // creating a circle contentunder.Circle(ptoX2, 612 - ptoY2 - r, r * 1.58); // Filling the circ //canvas.Fill(); contentunder.Stroke(); } //Sincronizar elipses y circulos foreach (var ellipse in ellipseList) { System.Drawing.Rectangle rr = ellipse.RotatedRect.MinAreaRect(); double propLeft = ((rr.Left * 100) / 640); double ptoLeft2 = ((propLeft * 792) / 100); double propRight = ((rr.Right * 100) / 640); double ptoRight2 = ((propRight * 792) / 100); double propBottom = ((rr.Bottom * 100) / 480); double ptoBottom2 = ((propBottom * 612) / 100); double propTop = ((rr.Top * 100) / 480); double ptoTop2 = ((propTop * 612) / 100); contentunder.SetColorStroke(BaseColor.GREEN); contentunder.Ellipse(ptoLeft2, 612 - ptoBottom2, ptoRight2, 612 - ptoTop2); /*double porcentajeB = (rr.Bottom * 100 / 640); * double nuevoPtoB = (porcentajeB * (841)) / 100; * double proporcionB = nuevoPtoB / rr.Bottom; * * double porcentajeT = (rr.Top * 100 / 640); * double nuevoPtoT = (porcentajeT * (841)) / 100; * double proporcionT = nuevoPtoB / rr.Top; * * contentunder.SetColorStroke(BaseColor.GREEN); * contentunder.Ellipse(rr.Left - 50, (841 * 0.9) - (nuevoPtoB), (rr.Right * 1.1) - 80, (841 * 0.9) - (nuevoPtoT));*/ contentunder.Stroke(); } stamper.Close(); reader.Close(); File.Replace(@newFile, oldFile, @"backup.pdf.bac"); //File.Replace(@"temporal.pdf", @"ejemploOK.pdf", @"backup.pdf.bac"); MessageBox.Show("Pdf modificado con exito, se ha guardado un backup de la versión anterior "); axAcroPDF1.src = "C:\\Users\\Denisse\\Desktop\\prototipos\\Prototipo4-FigurasFisicoDigital\\Prototipo4-FigurasFisicoDigital\\bin\\Debug\\opcion2X.pdf"; }