Search code examples
pdfsharp

How to save quality of pdf while converting it to jpeg


I use this function to convert pdf to jpeg. But quality is not so good as in original pdf.

var paths = new List<string>(gs.PdfToJpgFiles(filename, 1, pageCount, 200));

How to get max best quality, while not increasing time of conversion (dramatically)?


Solution

  • The fourth parameter (200 in your code snippet) specifies the resolution of the image create for the PDF page. I'm not sure if 200 means 200 dpi (it could even mean 100 dpi).

    Higher dpi values will lead to larger files and probably slower execution - but I don't think time will increase dramatically if you use a reasonable dpi value (I'd suggest 300 dpi or less - I presume that would be 600 used as the fourth parameter).

    A different matter is JPEG quality. If you see too many JPEG artefacts, try to use PNG instead.

    PDF is a vector format - even at 6400 % zoom level, text looks sharp. You'll never get this with any raster image (neither JPEG nor PNG).