HTML JPG PDF XML DOCX
  Product Family
PDF

Update PDF Forms in Node.js SDK

Update all of the form fields from a PDF Document using Node.js Cloud SDK

Get Started

How to update an AcroForms via Node.js SDK

The provided JavaScript code is designed to update form fields in a PDF document using the Aspose PDF Cloud API. It imports necessary modules, reads a local PDF file, uploads it to the cloud, and then updates specific fields in the PDF. The function updateFormFields encapsulates the entire process, handling both file operations and API interactions. It also includes error handling to manage potential issues during file reading and API requests.

In order to update 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 update AcroForms via Cloud Node.js

Aspose.PDF Cloud developers can easily load & update acroforms in PDF in just a few lines of code.

  1. Reads PDF file from local path.

  2. Upload the PDF file to the Aspose.PDF Cloud storage.

  3. Creates a new form field with the name “First Name” and sets its value to “James”.

  4. Updates the form fields in the PDF file on the Aspose.PDF Cloud storage.

  5. Download the result if needed it

  6. Download the result if needed it

 

This sample code shows updating 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 { Color } from "asposepdfcloud/src/models/color.js";
    import { FontStyles } from "asposepdfcloud/src/models/fontStyles.js";
    import { LineSpacing } from "asposepdfcloud/src/models/lineSpacing.js";
    import { Paragraph } from "asposepdfcloud/src/models/paragraph.js";
    import { TextHorizontalAlignment } from "asposepdfcloud/src/models/textHorizontalAlignment.js";
    import { VerticalAlignment } from "asposepdfcloud/src/models/verticalAlignment.js";
    import { WrapMode } from "asposepdfcloud/src/models/wrapMode.js";
    import { TextLine } from "asposepdfcloud/src/models/textLine.js";
    import { Segment } from "asposepdfcloud/src/models/segment.js";
    import { Rectangle } from "asposepdfcloud/src/models/rectangle.js";
    import { TextState } from "asposepdfcloud/src/models/textState.js";

    async function updateFormFields() {
        const localFileName = "C:\\Samples\\StudentInfoFormElectronic.pdf";
        const storageFileName = "StudentInfoFormElectronic.pdf";

        const pdfApi = new PdfApi(credentials.id, credentials.key);
        try {
            let fileData = await fs.readFile(localFileName);
            let uploadResult = await pdfApi.uploadFile(storageFileName, fileData);
            console.log(uploadResult.response.text);
        }
        catch (error) {
            console.error(error.message);
        }
        let field = new Field();
        field.name = "First Name";
        field.type = FieldType.Text;
        field.values = ["James"];
        field.rect = new Rectangle(125, 735, 200, 752);
        let fields = new Fields();
        fields.list = [field];
        try {
            let response = await pdfApi.putUpdateFields(storageFileName, fields);
            console.log(response.body.status);
        }
        catch (error) {
            console.log(error.message);
        }
    }
 

Work with the AcroForms via Node.js SDK

Updating AcroForms in a PDF involves modifying or enhancing existing interactive form fields. Improve field alignment, add tooltips, or adjust tab orders to make the form more intuitive and easier to use. Include additional fields such as checkboxes, dropdowns, or digital signature areas to accommodate new data collection needs. Update AcroForms to comply with accessibility standards, such as adding labels or improving compatibility with assistive technologies. Update AcroForms to ensure compatibility with modern devices, browsers, or software tools. Update 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 update the AcroForms into PDF files online and test the functionality.