> 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/core/low-level-pdf-api/add-custom.md).

# Information dictionary: adding custom data to a PDF on Server/Desktop

Learn how to add custom data to existing PDF documents using the Cos/SDF low-level API. Get a full code sample demonstrating how to edit PDF files efficiently. The Apryse Server SDK streamlines secure

To add custom data to an existing document.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
SDFDoc doc = new SDFDoc(filename);
Obj trailer = doc.GetTrailer();	// Get the trailer

// Create an Info dictionary
Obj info = trailer.PutDict("Info");
info.PutString("Producer", "Apryse PDFNet");

// Create a custom inline dictionary within Info dictionary
Obj custom_dict = info.PutDict("My Direct Dict");
custom_dict.PutNumber("My Number", 100);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
SDFDoc doc(filename);
Obj trailer = doc.GetTrailer();	// Get the trailer

// Create an Info dictionary
Obj info = trailer.PutDict("Info");
info.PutString("Producer", "Apryse PDFNet");

// Create a custom inline dictionary within Info dictionary
Obj custom_dict = info.PutDict("My Direct Dict");
custom_dict.PutNumber("My Number", 100);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
doc := NewSDFDoc(filename)
trailer := doc.GetTrailer()  // Get the trailer

// Create an Info dictionary
info = trailer.PutDict("Info")
info.PutString("Producer", "Apryse PDFNet")

// Create a custom inline dictionary within Info dictionary
customDict := info.PutDict("My Direct Dict")
customDict.PutNumber("My Number", 100)     // Add some key/value pairs
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
SDFDoc doc = new SDFDoc(filename);
Obj trailer = doc.getTrailer(); // Get the trailer

// Create an Info dictionary
Obj info = trailer.putDict("Info");
info.putString("Producer", "Apryse PDFNet");

// Create a custom inline dictionary within Info dictionary
Obj custom_dict = info.putDict("My Direct Dict");
custom_dict.putNumber("My Number", 100);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
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', 'Apryse 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);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
val doc = SDFDoc(filename)
val trailer = doc.trailer  // Get the trailer

// Create an Info dictionary
val info = trailer.putDict("Info")
info.putString("Producer", "Apryse PDFNet")

// Create a custom inline dictionary within Info dictionary
val custom_dict = info.putDict("My Direct Dict")
custom_dict.putNumber("My Number", 100.0)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
PTSDFDoc *doc = [[PTSDFDoc alloc] initWithFilepath: filename];
PTObj *trailer = [doc GetTrailer];  // Get the trailer

// Create an Info dictionary
PTObj *info = [trailer PutDict: @"Info"];
[info PutString: @"Producer" value: @"Apryse PDFNet"];

// Create a custom inline dictionary within Info dictionary
PTObj * custom_dict = [info PutDict: @"My Direct Dict"];
[custom_dict PutNumber: @"My Number" value: 100];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
let doc: PTSDFDoc = PTSDFDoc(filepath: filename, ofType: "pdf")
let trailer: PTObj = doc.getTrailer()  // Get the trailer

// Create an Info dictionary
let info = trailer.putDict("Info")
info.put("Producer", value: "Apryse PDFNet")

// Create a custom inline dictionary within Info dictionary
let custom_dict: PTObj = info.putDict("My Direct Dict")
custom_dict.putNumber("My Number", value: 100)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
// In case you have PDFDoc you can always access
// SDF/Cos document using PDFDoc.GetSDFDoc() method
$doc = new SDFDoc($filename);
$trailer = $doc->GetTrailer(); // Get the trailer

// Create an Info dictionary
$info = $trailer->PutDict("Info");
$info->PutString("Producer", "Apryse PDFNet");

// Create a custom inline dictionary within Info dictionary
$custom_dict = $info->PutDict("My Direct Dict");
$custom_dict->PutNumber("My Number", 100);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# In case you have PDFDoc you can always access
# SDF/Cos document using PDFDoc.GetSDFDoc() method
doc = SDFDoc(filename)
trailer = doc.GetTrailer()  # Get the trailer

# Create an Info dictionary
info = trailer.PutDict("Info")
info.PutString("Producer", "Apryse PDFNet")

# Create a custom inline dictionary within Info dictionary
custom_dict = info.PutDict("My Direct Dict")
custom_dict.PutNumber("My Number", 100)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
# In case you have PDFDoc you can always access
# SDF/Cos document using PDFDoc.GetSDFDoc() method
doc = SDFDoc.new(filename)
trailer = doc.GetTrailer  # Get the trailer

# Create an Info dictionary
info = trailer.PutDict("Info")
info.PutString("Producer", "Apryse PDFNet")

# Create a custom inline dictionary within Info dictionary
custom_dict = info.PutDict("My Direct Dict")
custom_dict.PutNumber("My Number", 100)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
' In case you have PDFDoc you can always access
' SDF/Cos document using PDFDoc.GetSDFDoc() method
Dim doc As SDFDoc = New SDFDoc(filename)
Dim trailer As Obj = doc.GetTrailer()		   ' Get the trailer

' Create an Info dictionary
info = trailer.PutDict("Info")
info.PutString("Producer", "Apryse PDFNet")

' Create a custom inline dictionary within Info dictionary
Dim custom_dict As Obj = info.PutDict("My Direct Dict")
custom_dict.PutNumber("My Number", 100)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Cos/SDF low-level API to edit PDF files - Full Sample](/core/get-started/samples/sdftest.md) Full code sample which illustrates how to use basic Cos/SDF API to edit an existing document. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB. To use this code, you'll need to [download and get started with Server SDK](/core/get-started/get-started.md).


---

# 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/core/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.
