How to fill PDF Form Field Values in C# .NET Framework

PDF forms are great and all, but have you ever tried interfacing with them directly using C#? It’s an absolute quagmire just waiting to suck in the unsuspecting programmer. If you don’t feel like having an overwhelming dose of tedium being added to your day, then allow me to demonstrate a super simple to use API that can get you up and running with form fields in no time.

First we install our package using NuGet:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Second comes our function call:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditPdfSetFormFieldsExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditPdfApi();var fieldValues = new SetPdfFormFieldsRequest(); // SetPdfFormFieldsRequest |try{// Sets ands fills PDF Form field valuesbyte[] result = apiInstance.EditPdfSetFormFields(fieldValues);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditPdfApi.EditPdfSetFormFields: " + e.Message );}}}}

And there you have it. Tied up nicely with a little bow for you.

Image for post
Image for post

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store