Update Metadata in PDF in Node.js SDK
Update all of the metadata from the PDF document using Cloud Node.js SDK
Get StartedHow to update Metadata via Node.js SDK
To update Metadata, 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 a Metadata via Cloud Node.js
Aspose.PDF Cloud developers can easily load & update metadata in PDF in just a few lines of code.
- Reads a PDF file from the local file system.
- Uploads the PDF file to the Aspose.PDF Cloud storage.
- Read the XMP metadata from pdf document using the Aspose.PDF Cloud API.
- Update the XMP metadata property using the Aspose.PDF Cloud API.
- Read an updated XMP metadata from pdf document using the Aspose.PDF Cloud API.
- Log to the console that the XMP metadata property was updated.
update Metadata in PDF using Node.js
const fs = require("fs");
const { PdfApi } = require("asposepdfcloud");
async function updateXmpMetadataProperty()
{
const api = new PdfApi("YOUR_API_SID", "YOUR_API_KEY");
const fileName = "Sample.pdf";
const folder = "Documents";
const storage = null;
const password = null;
const xmpMetadataProperty = "dc:title";
const buffer = fs.readFileSync(fileName);
await api.uploadFile(folder + "/" +fileName, buffer, storage)
var metadata = await api.getXmpMetadataJson(fileName, folder, storage, password);
var titleProperty = metadata.body.properties.find(property => property.key == xmpMetadataProperty);
titleProperty.value = "New title";
const xmpMetadata = {
properties: [titleProperty]
};
const result = await api.postXmpMetadata(fileName, xmpMetadata, folder, storage, password);
console.log(result.body.status);
metadata = await api.getXmpMetadataJson(fileName, folder, storage, password);
titleProperty = metadata.body.properties.find(property => property.key == xmpMetadataProperty);
console.log("Updated xmpMetadataProperty: " + titleProperty.key + "=" + titleProperty.value);
}
Work with Metadata in PDF
Working with metadata in PDF files is important. Metadata such as the title field, author and theme help classify documents, making it easier to manage large collections of documents by providing a quick overview of content without opening files. Metadata also improves file search by allowing you to search by keywords and attributes. This is particularly valuable in systems where the rapid retrieval of documents is essential. Add metadata 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 metadata in 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