What you need: open an A4 scan (scans will always be used), reduce its size by 2 times, place it on 1/4 of an A4 sheet and place the result in pdf.

There is a scan in the resolution of 2464: 3424 and 300dpi, jpg format. I use library itextsharp. The problem is that the print quality is rather poor, grainy, despite the fact that I have a 1200dpi laser printer and a high resolution image (as I think). I print using Foxit Reader, with 1200dpi in the printer settings. Main code:

public void CreatePdf(string path, System.Drawing.Image image) { var doc = new Document(); PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create)); var a4Size = new Rectangle(PageSize.A4); doc.SetPageSize(a4Size); var width = 297; var height = 421; // Половины от PageSize.A4 _neededSize = new Rectangle(width, height); var table = new PdfPTable(2); var img = iTextSharp.text.Image.GetInstance(image, System.Drawing.Imaging.ImageFormat.Jpeg); img.ScaleToFit(_neededSize); table.AddCell(img); doc.Add(table); doc.Close(); } 

Reading the picture is as follows:

 var img = Image.FromFile(fileName); 

I tried to immediately print using C #, the quality did not improve. Although the "TK" should be pdf.

What could be the problem in the insufficient resolution of the source material? In English-language forums, it is advised to increase the resolution of pictures, but I do not understand what I mean: to slip pictures of higher quality or programmatically produce some kind of manipulation.

But in the pdf file there is no quality loss. And the pdf is the same size (in KB, I mean) as the picture. That is, do I understand correctly that foxit compresses before printing? In that case, is there any way to improve this result? To process the image somehow?

Maybe it is worth using other libraries?

  • Do I understand correctly that the code is working fine: you get a high-quality, clear PDF file. The problem only occurs when printing through Foxit Reader? - default locale
  • @defaultlocale Yes, that's right. - KhomRud
  • And tried to type pens without any? The printer has its own parameters ... - iluxa1810

1 answer 1

Turned on the brain and tried to print the scan using the "image viewer" from Windows and MS Word (they said on the Internet that compresses well for printing). Got about the same quality with my version. And although this does not give an answer to the question of improving the quality, this question can be considered closed - the image was printed as it should have been.

Apparently the solution to my problem lies in converting the image to improve the quality even before it is placed in PDF.

Thank you and apologize for the time spent.