How to create an AcroForm via Node.js SDK
In order to create an AcroForm to PDF, we’ll use Aspose.PDF Cloud Node.js SDK. This Cloud SDK assists Node.js programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Node.js programming language via Aspose.PDF REST API. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Node.js SDK.
Package Manager Console Command
npm install asposepdfcloud --save
Steps to create AcroForms via Node.js
Aspose.PDF Cloud developers can easily load & create acroforms in PDF in just a few lines of code.
- Uploads the PDF file to the Aspose.PDF Cloud service.
- Creates a new text box field with the necessary properties
- Adds the text box field to the PDF file stored in the Aspose.PDF Cloud service.
- Download the result if needed it
This sample code shows creating an AcroForms in PDF documents using Node.js
import credentials from "./credentials.json" with { type: "json" };
import fs from 'node:fs/promises';
import { PdfApi } from "asposepdfcloud";
import { Border } from "asposepdfcloud/src/models/border.js"
import { TextBoxField } from "asposepdfcloud/src/models/textBoxField.js";
import { Dash } from "asposepdfcloud/src/models/dash.js";
import { Rectangle } from "asposepdfcloud/src/models/rectangle.js";
import { Field } from "asposepdfcloud/src/models/field.js";
import { FieldType } from "asposepdfcloud/src/models/fieldType.js";
import { Fields } from "asposepdfcloud/src/models/fields.js";
async function addFormField () {
const LOCAL_FILE_NAME = "C:\\Samples\\StudentInfoFormElectronic.pdf";
const STORAGE_FILE_NAME = "StudentInfoFormElectronic.pdf";
const pdfApi = new PdfApi(credentials.id, credentials.key);
try {
let fileData = await fs.readFile(LOCAL_FILE_NAME);
let uploadResult = await pdfApi.uploadFile(STORAGE_FILE_NAME, fileData);
console.log(uploadResult.response.text);
}
catch (error) {
console.error(error.message);
}
let textBoxField = new TextBoxField();
textBoxField.pageIndex = 1;
textBoxField.partialName = "Email";
textBoxField.rect = new Rectangle(100, 100, 180, 120);
textBoxField.value = "aspose-pdf-cloud@example.com";
let border = new Border();
border.width = 5;
border.dash = new Dash(1, 1);
textBoxField.Border = border;
try {
let response = await pdfApi.putTextBoxField(STORAGE_FILE_NAME, "Email", textBoxField);
console.log(response.body.status);
const downloadRes = await pdfApi.downloadFile(STORAGE_FILE_NAME)
await fs.writeFile(RESULT_FILE_NAME, downloadRes.body);
} catch (error) {
console.log(error.message);
}
}
Work with the AcroForms via Node.js SDK
AcroForms allows users to interact directly with the PDF by filling out fields, selecting options, or clicking buttons, making the document more dynamic. Interactive forms enable efficient data collection, reducing the need for manual data entry or external tools. This is ideal for surveys, registrations, and application processes. Users can fill in forms electronically without printing, scanning, or using other tools, saving time and effort. Including AcroForms in documents creates a polished and modern presentation, reflecting professionalism and attention to detail. Add the AcroForms into PDF documents with Aspose.PDF Cloud Node.js SDK.
With our Node.js library you can
- Add PDF document’s header & footer in text or image format.
- Add tables & stamps (text or image) to PDF documents.
- Append multiple PDF documents to an existing file.
- Work with PDF attachments, annotations, & form fields.
- Apply encryption or decryption to PDF documents & set a password.
- Delete all stamps & tables from a page or entire PDF document.
- Delete a specific stamp or table from the PDF document by its ID.
- Replace single or multiple instances of text on a PDF page or from the entire document.
- Extensive support for converting PDF documents to various other file formats.
- Extract various elements of PDF files & make PDF documents optimized.
- You can try out our free App to add the AcroForms into PDF files online and test the functionality.
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for Node.js?
- Customers List
- Security