Skip to content

Navigation Menu

Sign in
Sign up

Are there compression options? #263

Unanswered
RevitArkitek asked this question in Q&A
Discussion options

I have a 3 page pdf. In my app I deleted the 3rd page. The file size went up 2 kb, I expected it to go down. ChatGPT says PDFsharp doesn't do compression. Is this true? Is there anything I can do or I need to look for a different option?

You must be logged in to vote

Replies: 2 comments

Comment options

For compression, you could try a combination of these options:

doc.Options.CompressContentStreams = true;
doc.Options.EnableCcittCompressionForBilevelImages = true;
doc.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
doc.Options.UseFlateDecoderForJpegImages = PdfUseFlateDecoderForJpegImages.Always;

where doc is an instance of a PdfDocument.

Regarding the deletion of pages, see #141

You must be logged in to vote
0 replies
Comment options

Never trust the first answer from ChatGPT. Things are complicated.

PDFsharp supports compression, as packdat already pointed out. But PDFsharp does not support XREF streams, so files containing XREF streams will usually grow in size when being processed with PDFsharp.
So yes, sometimes files will grow in size even if you only remove a page.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /