Update PDF Forms in .NET SDK
Update all of the form fields from the PDF document using Aspose.PDF Cloud .NET API
Get StartedHow to Update Form Fields from PDF Document using Cloud .NET SDK
In order to update an AcroForm via Cloud .NET SDK , we’ll use
Aspose.PDF Cloud .NET SDK
This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open
NuGet
package manager, search for
Aspose.PDF Cloud
and install. You may also use the following command from the Package Manager Console: PM> Install-Package Aspose.Pdf-Cloud
Steps to update AcroForms via .NET SDK
Aspose.PDF Cloud developers can easily load & update acroforms in PDF in just a few lines of code.
- Create a new Configuration object with your Application Secret and Key
- Create an object to connect to the Cloud API
- Upload your document file
- Perform the updating
- Download the result
This sample code shows updating the AcroForms in PDF documents
public static async Task UpdateFormFields()
{
const string localImageFileName = @"C:\Samples\sample.pdf";
const string storageFileName = "sample.pdf";
const string localFolder = @"C:\\Samples";
const string resultFileName = "output_update_form_filed.pdf";
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
var filesOnStorage = await pdfApi.GetFilesListAsync("");
if (filesOnStorage.Value.All(f => f.Name != storageFileName))
{
using var file = File.OpenRead(localImageFileName);
var uploadResult = await pdfApi.UploadFileAsync(storageFileName, file);
Console.WriteLine(uploadResult.Uploaded[0]);
}
var fieldList = new List<Field>
{
new Field(
Name: "First Name",
Type: FieldType.Text,
Values: ["James"],
Rect: new Rectangle(125, 735, 200, 752))
};
var fields = new Fields(List: fieldList);
var response = await pdfApi.PutUpdateFieldsAsync(storageFileName, fields);
Console.WriteLine(response.Status);
using Stream downloadStream = await pdfApi.DownloadFileAsync(storageFileName);
using FileStream localStream = File.Create(Path.Combine(localFolder, resultFileName));
await downloadStream.CopyToAsync(localStream);
}
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security