PdfDocumentProcessor.SaveDocument(Stream) Method
Saves the current document to the specified file stream.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v19.1.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
stream | Stream | A Stream value, specifying the location of the saved document. |
Remarks
When you dispose of an output stream that has not been detached, an attempt to apply further changes to a document may cause errors. If you want to close the stream when a document is saved, call the SaveDocument method overload with the detachStream parameter enabled.
Important
If you load and save a document to the same stream, it may lead to unexpected results. Use the PdfDocumentProcessor.SaveDocument(Stream, PdfSaveOptions, Boolean) method overload for safer results.
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 (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
documentProcessor.LoadDocument(filePath + fileName + ".pdf");
// Obtain interactive form data from a document.
PdfFormData formData = 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.
PdfFormData address = 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;
}