> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/low-level-pdf-api/add-custom.md).

# Information dictionary: adding custom data to a PDF using JavaScript

Learn how to add custom data to an existing document using the Cos/SDF low-level API to edit PDF files. Get a full code sample demonstrating the use of basic Cos/SDF API for document editing. The Apry

{% hint style="warning" %}
Make sure you have [Full API enabled in WebViewer.](/web/what-is-webviewer/full-api.md)
{% endhint %}

To add custom data to an existing document.

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
<html>
  <script src="../lib/core/webviewer-core.min.js"></script>
  <script src="../lib/core/pdf/PDFNet.js"></script>
  <script>
    (async function() {
      Core.setWorkerPath('../lib/core');

      // 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', 'Apryse PDFNet');

      // Create a custom inline dictionary within Infor dictionary
      const customDict = await info.putDict('My Direct Dict');
      customDict.putNumber('My Number', 100);
    })()
  </script>
</html>
```

{% endcode %}

[PDFNet.PDFDoc.createFromURL](https://sdk.apryse.com/api/web/Core.PDFNet.PDFDoc.html#.createFromURL__anchor) [PDFNet.PDFDoc.getSDFDoc](https://sdk.apryse.com/api/web/Core.PDFNet.PDFDoc.html#getSDFDoc__anchor) [PDFNet.PDFDoc.getTrailer](https://sdk.apryse.com/api/web/Core.PDFNet.PDFDoc.html#getTrailer__anchor) [PDFNet.Obj.putDict](https://sdk.apryse.com/api/web/Core.PDFNet.Obj.html#putDict__anchor) [PDFNet.Obj.putString](https://sdk.apryse.com/api/web/Core.PDFNet.Obj.html#putString__anchor) [PDFNet.Obj.putNumber](https://sdk.apryse.com/api/web/Core.PDFNet.Obj.html#putNumber__anchor) [Core.setWorkerPath](https://sdk.apryse.com/api/web/Core.html#.setWorkerPath__anchor)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
<html>
  <script src="../lib/core/CoreControls.js"></script>
  <script src="../lib/core/pdf/PDFNet.js"></script>
  <script>
    (async function() {
      CoreControls.setWorkerPath('../lib/core');

      // 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', 'Apryse PDFNet');

      // Create a custom inline dictionary within Infor dictionary
      const customDict = await info.putDict('My Direct Dict');
      customDict.putNumber('My Number', 100);
    })()
  </script>
</html>
```

{% endcode %}

[PDFNet.PDFDoc.createFromURL](https://sdk.apryse.com/api/web/Core.PDFNet.PDFDoc.html#.createFromURL__anchor) [PDFNet.PDFDoc.getSDFDoc](https://sdk.apryse.com/api/web/Core.PDFNet.PDFDoc.html#getSDFDoc__anchor) [PDFNet.PDFDoc.getTrailer](https://sdk.apryse.com/api/web/Core.PDFNet.PDFDoc.html#getTrailer__anchor) [PDFNet.Obj.putDict](https://sdk.apryse.com/api/web/Core.PDFNet.Obj.html#putDict__anchor) [PDFNet.Obj.putString](https://sdk.apryse.com/api/web/Core.PDFNet.Obj.html#putString__anchor) [PDFNet.Obj.putNumber](https://sdk.apryse.com/api/web/Core.PDFNet.Obj.html#putNumber__anchor) [CoreControls.setWorkerPath](https://sdk.apryse.com/api/web/Core.html#.setWorkerPath__anchor)
{% endtab %}
{% endtabs %}

[Cos/SDF low-level API to edit PDF files](/web/get-started/samples.md#sdf) Full code sample which illustrates how to use basic Cos/SDF API to edit an existing document.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/low-level-pdf-api/add-custom.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
