Hello Friends,
I have to print windows form using in to PDF. I used itextsharp for print gridview but This time I need to print some label.
Is Itextsharp is good or should I use another one. and how can I print labels
Please Help me.
//code
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();
}
}
}
}
I used this code but iTs print like screen shot.
Thanks
Neetesh Agarwal