Click or drag to resize
Pdf Library for .NET

PdfFormManagerCompactSave Property

Gets or sets a value indicating whether the document is rewritten from scratch on save instead of being updated incrementally. Default is false.

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public bool CompactSave { get; set; }

Property Value

Boolean
Remarks

By default a save APPENDS the changes to the bytes of the loaded document, which is what keeps an existing digital signature verifiable: the signed bytes are still there, untouched, and a reader can still check them. The cost is that nothing is ever reclaimed - an output is always larger than its input, and content the save REMOVED is unlinked rather than deleted. The clearest case is an XFA hybrid form: filling it drops the /XFA entry (the AcroForm becomes the single source of truth) but the XFA packets themselves stay in the file, unreachable and often the bulk of it.

Setting this to true writes a fresh document containing only what is still reachable, so the orphaned packets and the appearance streams of flattened fields go with it. Measured on the IRS W-9 (an XFA hybrid): 148 KB incrementally, 97 KB rewritten, with the 251 KB of XFA XML gone. Set it when output size matters and no signature has to survive; leave it alone when one does.

Example
PdfFormManager manager = new PdfFormManager();
manager.Load("form.pdf");
manager.CompactSave = true;
manager.Save("filled.pdf");
See Also