/** * @see com.lowagie.text.pdf.draw.DrawInterface#draw(com.lowagie.text.pdf.PdfContentByte, float, float, float, float, float) */ public override void Draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.SaveState(); canvas.SetLineWidth(lineWidth); canvas.SetLineCap(PdfContentByte.LINE_CAP_ROUND); canvas.SetLineDash(0, gap, gap / 2); DrawLine(canvas, llx, urx, y); canvas.RestoreState(); }
/// <summary> /// Draws the page border. /// </summary> /// <param name="writer"> </param> /// <param name="document"> </param> /// <param name="canvas"> </param> /// <returns></returns> protected void DrawPageBorder(PdfWriter writer, Document document, PdfContentByte canvas) { var pageBorderRect = new Rectangle(document.PageSize); var content = writer.DirectContent; pageBorderRect.Left += document.LeftMargin - BorderDifference; pageBorderRect.Right -= document.RightMargin - BorderDifference; pageBorderRect.Top -= document.TopMargin - BorderDifference; pageBorderRect.Bottom += document.BottomMargin - BorderDifference; content.SetColorStroke(BaseColor.BLACK); canvas.SetLineWidth(FillOpacity); canvas.SetRGBColorStroke(0, 0, 0); canvas.SetLineDash(6f, 6f, 0f); content.Rectangle(pageBorderRect.Left, pageBorderRect.Bottom, pageBorderRect.Width, pageBorderRect.Height); content.Stroke(); }
// --------------------------------------------------------------------------- /** * Draws the time slots for a day at the film festival. * @param directcontent the canvas to which the time table has to be drawn. */ protected void DrawTimeSlots(PdfContentByte directcontent) { directcontent.SaveState(); float x; for (int i = 1; i < TIMESLOTS; i++) { x = OFFSET_LEFT + (i * WIDTH_TIMESLOT); directcontent.MoveTo(x, OFFSET_BOTTOM); directcontent.LineTo(x, OFFSET_BOTTOM + HEIGHT); } directcontent.SetLineWidth(0.3f); directcontent.SetColorStroke(BaseColor.GRAY); directcontent.SetLineDash(3, 1); directcontent.Stroke(); directcontent.RestoreState(); }
void SetLineDash(PdfContentByte cb, IDictionary<String, String> css) { String lineDash; if (!css.TryGetValue(SVGAttributes.STROKE_DASHARRAY, out lineDash) || lineDash == null || lineDash.Equals("none")) { return; } IList<String> list = tags.TagUtils.SplitValueList(lineDash); if (list == null) return; float[] phase = new float[list.Count * 2]; //the lineDash was validated before adding to CSS, so this is a valid pattern bool allZero = true; int i = 0; foreach (String str in list) { try { phase[i] = int.Parse(str); phase[i + list.Count] = phase[i]; if (phase[i] != 0) { allZero = false; } i++; } catch { } } if (!allZero) { cb.SetLineDash(phase, 0); } }