You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Library/NET/Working-with-forms.md
+128Lines changed: 128 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5101,6 +5101,134 @@ doc.Close(True)
5101
5101
5102
5102
{% endtabs %}
5103
5103
5104
+
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Forms/Auto-resize-the-text-of-textboxfield-in-a-PDF).
5105
+
5106
+
## Preserve form fields when creating a PDF Template from an existing page
5107
+
5108
+
When you create a [PdfTemplate](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfTemplate.html) from an existing page, interactive **AcroForm** fields (textbox, checkbox, etc.) are **not copied** to the template.
5109
+
If you still need the visual appearance of those form fields in the final document, you can flatten the form using the [FlattenFields](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.PdfLoadedForm.html#Syncfusion_Pdf_Parsing_PdfLoadedForm_FlattenFields) API.
5110
+
5111
+
Please refer the code sample to flatten the form fields before saving the PDF document.
5112
+
5113
+
N> Flattening permanently removes interactivity. The resulting PDF shows the form content exactly as it appears on screen, but users can no longer edit the fields.
Dim loadedDocument As New PdfLoadedDocument("Form.pdf")
5201
+
5202
+
'Flatten all form fields.
5203
+
Dim loadedForm As PdfLoadedForm = loadedDocument.Form
5204
+
loadedForm.FlattenFields()
5205
+
5206
+
'Create a template from the first page.
5207
+
Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage)
5208
+
Dim template As PdfTemplate = loadedPage.CreateTemplate()
5209
+
5210
+
'Create the destination PDF.
5211
+
Dim newDocument As New PdfDocument()
5212
+
newDocument.PageSettings.Margins.All = 0
5213
+
Dim newPage As PdfPage = newDocument.Pages.Add()
5214
+
5215
+
'Draw the template so it fills the entire new page.
5216
+
newPage.Graphics.DrawPdfTemplate(
5217
+
template,
5218
+
PointF.Empty,
5219
+
New SizeF(newPage.Size.Width, newPage.Size.Height))
5220
+
5221
+
'Save the result.
5222
+
newDocument.Save("Output.pdf")
5223
+
5224
+
'Close documents.
5225
+
loadedDocument.Close(True)
5226
+
newDocument.Close(True)
5227
+
End Using
5228
+
{% endhighlight %}
5229
+
5230
+
{% endtabs %}
5231
+
5104
5232
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Forms/Auto-resize-the-text-of-textboxfield-in-a-PDF).
0 commit comments