For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Friday, November 15, 2013

image quality in iTextSharp

How to improve image quality in iTextSharp.

I was working in question paper project. in this project I need to generate PDF file from images. but when I generated the PDF file, image's quality was so bad. so to overcome this problem I have used listed below code.


 System.Drawing.Image image = System.Drawing.Image.FromFile("myimage.jpg");
 iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4);
 doc.Open();
 doc.Add(new Paragraph(""));
 PdfWriter.GetInstance(doc, new FileStream("my.pdf", FileMode.Create));
 iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(image, System.Drawing.Imaging.ImageFormat.Jpeg);
pdfImage.ScalePercent(50f);
doc.Add(pdfImage);
doc.Close();

Share:

0 comments:

Post a Comment

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip