Some test text!

Loading...
Guides
Info dictionary

Information dictionary: adding custom data to a PDF in Node.js

To add custom data to an existing document.

async function main() {
  // In case you have PDFDoc you can always access
  // SDF/Cos document using PDFDoc.GetSDFDoc() method
  const pdf_doc = await PDFNet.PDFDoc.createFromURL(filename);
  const doc =  await pdf_doc.getSDFDoc();
  const trailer = await doc.getTrailer(); // Get the trailer

  // Create an Info dictionary
  const info = await trailer.putDict('Info');
  info.putString('Producer', 'PDFTron PDFNet');

  // Create a custom inline dictionary within Infor dictionary
  const customDict = await info.putDict('My Direct Dict');
  customDict.putNumber('My Number', 100);
}
PDFNet.runWithCleanup(main);

Cos/SDF low-level API to edit PDF files
Full code sample which illustrates how to use basic Cos/SDF API to edit an existing document.

Get the answers you need: Support

Upcoming Webinar: Live tech update & run-through: Redaction | March 31st at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use