private void button13_Click(object sender, System.EventArgs e) { C1.C1Pdf.C1PdfDocument pdf = new C1.C1Pdf.C1PdfDocument(); // create a thin (hairline) black pen Pen thinPen = new Pen(Color.Black, 0); // create a thick (3pt) blue pen Pen thickPen = new Pen(Color.Blue, 3); // create a thick (2pt) dotted red pen Pen dotPen = new Pen(Color.Red, 2); dotPen.DashStyle = DashStyle.Dot; // draw some lines pdf.DrawLine(thinPen, 100, 100, 300, 100); pdf.DrawLine(thickPen, 100, 120, 300, 120); pdf.DrawLine(dotPen, 100, 140, 300, 140); // save the document to a file string fileName = tempdir + "drawline.pdf"; pdf.Save(fileName); System.Diagnostics.Process.Start(fileName); }
internal RectangleF RenderParagraph(string text, Font font, RectangleF rcPage, RectangleF rc, bool outline, bool linkTarget) { // if it won't fit this page, do a page break rc.Height = _c1pdf.MeasureString(text, font, rc.Width).Height; if (rc.Bottom > rcPage.Bottom) { _c1pdf.NewPage(); rc.Y = rcPage.Top; } // draw the string _c1pdf.DrawString(text, font, Brushes.Black, rc); // show bounds (mainly to check word wrapping) // _c1pdf.DrawRectangle(Pens.Sienna, rc); // add headings to outline if (outline) { _c1pdf.DrawLine(Pens.Black, rc.X, rc.Y, rc.Right, rc.Y); _c1pdf.AddBookmark(text, 0, rc.Y); } // add link target if (linkTarget) { _c1pdf.AddTarget(text, rc); } // update rectangle for next time rc.Offset(0, rc.Height); return(rc); }
private void AddFooters() { Font fontHorz = new Font("Tahoma", 7, FontStyle.Bold); Font fontVert = new Font("Viner Hand ITC", 14, FontStyle.Bold); StringFormat sfRight = new StringFormat(); sfRight.Alignment = StringAlignment.Far; StringFormat sfVert = new StringFormat(); sfVert.FormatFlags |= StringFormatFlags.DirectionVertical; sfVert.Alignment = StringAlignment.Center; for (int page = 0; page < _c1pdf.Pages.Count; page++) { // select page we want (could change PageSize) _c1pdf.CurrentPage = page; // build rectangles for rendering text RectangleF rcPage = GetPageRect(); RectangleF rcFooter = rcPage; rcFooter.Y = rcFooter.Bottom + 6; rcFooter.Height = 12; RectangleF rcVert = rcPage; rcVert.X = rcPage.Right + 6; // add left-aligned footer string text = _c1pdf.DocumentInfo.Title; _c1pdf.DrawString(text, fontHorz, Brushes.Gray, rcFooter); // add right-aligned footer text = string.Format("Page {0} of {1}", page + 1, _c1pdf.Pages.Count); _c1pdf.DrawString(text, fontHorz, Brushes.Gray, rcFooter, sfRight); // add vertical text text = _c1pdf.DocumentInfo.Title + " (document created using the C1Pdf .NET component)"; _c1pdf.DrawString(text, fontVert, Brushes.LightGray, rcVert, sfVert); // draw lines on bottom and right of the page _c1pdf.DrawLine(Pens.Gray, rcPage.Left, rcPage.Bottom, rcPage.Right, rcPage.Bottom); _c1pdf.DrawLine(Pens.Gray, rcPage.Right, rcPage.Top, rcPage.Right, rcPage.Bottom); } }