PDFsharp has some options you can use to control compression.
You can activate some options to generate smaller PDF files – at the price of longer creation times.
To create small PDF files, I recommend these settings:
Code:
document.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
document.Options.UseFlateDecoderForJpegImages = PdfUseFlateDecoderForJpegImages.Automatic;
document.Options.NoCompression = false;
// Defaults to false in debug build, so we set it to true.
document.Options.CompressContentStreams = true;
And how to do it with MigraDoc?The "PdfDocumentRenderer" class creates the "PdfDocument" object when needed. Just create the PdfDocument object yourself before doing anything with the renderer.
Code:
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
pdfRenderer.PdfDocument = new PdfDocument();
pdfRenderer.PdfDocument.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
This post applies to PDFsharp 1.50. Older versions may not have the settings described here, newer versions may have more or different options.
See the full blog post here:
http://developer.th-soft.com/developer/ ... s/#more-94