3

I would like to take a single page jpg, and experiment with various pdf compression settings and other settings (to analyse resultant pdf size and quality) - can anyone point me towards decent tools to do this, and any useful docs/guides?

brucem
  • 341
  • 3
  • 11

3 Answers3

1

Adobe Acrobat Distiller, Ghostscript, possibly others. Acrobat has its own manual, Ghostscript documentation can be found at:

http://svn.ghostscript.com/ghostscript/tags/ghostscript-9.02/doc/Ps2pdf.htm

for the current version PostScript to PDF conversion (print your JPEG to a PostScript file before starting).

If your original is a JPEG, then the best quality output will be to do nothing at all to it, simply wrap it up in PDF syntax.

If you insist on downsampling the image data (which is the only way you are going to reduce the size of a JPEG image) then you would be advised not to use DCT (JPEG) compression in the PDF file, as this will introduce objectionable artefacts.

You should use a lossless compression scheme instead, eg *"Flate".

Your best bet would be to go back to an original which has not been stored as a JPEG, downsample in a decent image application and then convert to JPEG and wrap that up in a PDF.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
KenS
  • 30,202
  • 3
  • 34
  • 51
1

Docotic.Pdf library can be used to add JPEGs (with or without recompression) to PDF.

Please take a look at sample that shows how to recompress images before adding them to PDF. With help of the library you can recompress existing images too.

Disclaimer: I work for Bit Miracle, vendor of the library.

Bobrovsky
  • 13,789
  • 19
  • 80
  • 130
0

If you're OK working with .NET on Windows, my company, Atalasoft, has tools for creating image PDFs. You can tweak the compression very easily using code like this:

public void WriteJpegPdf(AtalaImage image, Stream outStream)
{
    PdfEncoder encoder = new PdfEncoder();
    encoder.JpegQuality = 60; // 0 - 100
    encoder.Save(outStream, image, PdfCompressionType.Jpeg);
}

This is the simplest way of hitting the jpeg quality. It will override your setting if the image isn't 24 bit rgb or 8 bit gray.

If you are concerned with encoding a bunch of files but want fine-grained control over compression, the encoder has an event, SetEncoderCompression, that is invoked before the image is encoded to let you see what the encoder chose and you can override it if you like.

FWIW, I wrote most of the PDF Encoder and the underlying layer that exports the actual PDF.

plinth
  • 48,267
  • 11
  • 78
  • 120