Create a portrait gallery

Jérémy R 1 Reputation point


I want to create a portrait gallery with some photos. In order to achieve this, I add everything I need in a panel and then I get the visual of this panel to add it in a PDF.

My problem is that I managed to create the PDF containing the image, but it is bad quality.


We see that the outline of peoples is not clear, while in the original photos the outline is very clear.

iTextSharp.text.Document doc = new iTextSharp.text.Document();

panelTombi.AutoScrollPosition = new Point(0, 0);
panelTombi.AutoSize = true;
int width = panelTombi.Width;
int height = panelTombi.Height;

Bitmap MemoryImage = new Bitmap(width, height);

panelTombi.DrawToBitmap(MemoryImage, new System.Drawing.Rectangle(0, 0, width, height));

iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance((System.Drawing.Image)MemoryImage, System.Drawing.Imaging.ImageFormat.Jpeg);

image1.SetAbsolutePosition(0, PageSize.A4.Height - image1.ScaledHeight - doc.TopMargin);
MemoryImage.Save(Path.GetDirectoryName(sfd.FileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(sfd.FileName) + ".jpeg"); 

//Save pdf file
PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));

As you can see, the image is also saved.

The image has always a good quality but some pixels are white:
But the PDF has always the same problem no matter the image format, the outline of people is not sharp.

Could you tell me how to fix this image quality problem on the PDF file?

Thank you

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,524 questions
{count} votes