PdfDocumentProcessor.LoadDocument(Stream, Boolean) Method
Opens a PDF document from the specified stream using detach stream mode.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v18.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
stream | Stream | A Stream object. |
detachStreamAfterLoadComplete | Boolean | true the PDF Document API component completes all input operations after loading a document; false the stream should not be closed or modified until the PDF Document API component finishes using a document. |
Remarks
When loading a document, the PDF Document API component expects that the input stream will not be modified or closed before the component finishes using a document (the detachStreamAfterLoadComplete parameter is set to false by default).
If you want to close or modify the stream after a document is loaded to the PDF Document API component, call the overloaded LoadDocument method with the detachStreamAfterLoadComplete parameter enabled.
Example
The example shows how to fill an existing interactive form using field names.
To obtain interactive form data, call the PdfDocumentProcessor.GetFormData method. Then, specify a value for a form field using the PdfFormData.Value property.
To obtain the names of the interactive form fields, use the PdfDocumentProcessor.GetFormFieldNames method.
To apply data to the interactive form, call the PdfDocumentProcessor.ApplyFormData method.
To learn how to get a checked appearance name for the check box, see the How to: Obtain a Checked Appearance Name for a Check Box example.
To learn how to get a checked appearance name for the radio button, see the How to: Obtain a Checked Appearance Name for Each Radio Button in the Radio Group example.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-programmatically-fill-an-interactive-form-with-values-t210253
' Load a document with an interactive form.
Using documentProcessor As New PdfDocumentProcessor()
documentProcessor.LoadDocument(filePath & fileName & ".pdf")
' Obtain interactive form data from a document.
Dim formData As PdfFormData = documentProcessor.GetFormData()
' Specify the value for FirstName and LastName text boxes.
formData("FirstName").Value = "Janet"
formData("LastName").Value = "Leverling"
' Specify the value for the Gender radio group.
formData("Gender").Value = "Female"
' Specify the check box checked appearance name.
formData("Check").Value = "Yes"
' Specify values for the Category list box.
formData("Category").Value = New String() { "Entertainment", "Meals", "Morale" }
' Obtain data from the Address form field and specify values for Address child form fields.
Dim address As PdfFormData = formData("Address")
' Specify the value for the Country combo box.
address("Country").Value = "United States"
' Specify the value for City and Address text boxes.
address("City").Value = "California"
address("Address").Value = "20 Maple Avenue"
' Apply data to the interactive form.
documentProcessor.ApplyFormData(formData)
' Save the modified document.
documentProcessor.SaveDocument(filePath & fileName & "_new.pdf")
btnFillFormData.Enabled = False
btnLoadFilledPDF.Enabled = True
End Using
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the LoadDocument(Stream, Boolean) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.