using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using iTextSharp; using iTextSharp.text; using iTextSharp.text.pdf; using System.IO;
namespace ghm_scrum { public partial class View_Incident : Form { private void btnPrint_Click(object sender, EventArgs e) { using (Bitmap b = new Bitmap(this.Width, this.Height)) { using (Graphics g = Graphics.FromImage(b)) { g.CopyFromScreen(this.Location, new Point(0, 0), this.Size); } Document doc = new Document(); iTextSharp.text.Image i = iTextSharp.text.Image.GetInstance(b, System.Drawing.Imaging.ImageFormat.Bmp); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"D:\output.pdf", FileMode.Create)); doc.SetPageSize(new iTextSharp.text.Rectangle(this.Size.Width + doc.LeftMargin + doc.RightMargin, this.Size.Height + doc.TopMargin + doc.BottomMargin)); doc.Open(); doc.Add(i); doc.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)