Skip to content

Commit 4449f81

Browse files
authored
Implement missing XForm.Finish() method
1 parent 8b9076c commit 4449f81

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

PdfSharpCore/Drawing/XForm.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,28 @@ protected override void Dispose(bool disposing)
177177
/// </summary>
178178
internal virtual void Finish()
179179
{
180+
if (_formState == FormState.NotATemplate || _formState == FormState.Finished)
181+
return;
182+
183+
Debug.Assert(_formState == FormState.Created || _formState == FormState.UnderConstruction);
184+
_formState = FormState.Finished;
185+
Gfx.Dispose();
186+
Gfx = null;
187+
188+
if (PdfRenderer != null)
189+
{
190+
//pdfForm.CreateStream(PdfEncoders.RawEncoding.GetBytes(PdfRenderer.GetContent()));
191+
PdfRenderer.Close();
192+
Debug.Assert(PdfRenderer == null);
193+
194+
if (_document.Options.CompressContentStreams)
195+
{
196+
_pdfForm.Stream.Value = Filtering.FlateDecode.Encode(_pdfForm.Stream.Value, _document.Options.FlateEncodeMode);
197+
_pdfForm.Elements["/Filter"] = new PdfName("/FlateDecode");
198+
}
199+
int length = _pdfForm.Stream.Length;
200+
_pdfForm.Elements.SetInteger("/Length", length);
201+
}
180202
}
181203

182204
/// <summary>
@@ -437,4 +459,4 @@ string IContentStream.GetFormName(XForm form)
437459
internal XGraphicsPdfRenderer PdfRenderer;
438460

439461
}
440-
}
462+
}

0 commit comments

Comments
 (0)