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

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip