PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 11:20 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Mar 25, 2018 11:33 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 906
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group