> 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/portfolio/create.md).

# Create a PDF portfolio (package) on Server/Desktop

Learn how to create a PDF portfolio with multiple file types using our full code sample. Explore how to create, extract, and manipulate PDF Packages efficiently. The Apryse Server SDK streamlines secu

To create a PDF portfolio containing multiple file types.

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

```csharp
void AddPackage(PDFDoc doc, string file, string desc)
{
	NameTree files = NameTree.Create(doc, "EmbeddedFiles");
	FileSpec fs = FileSpec.Create(doc, file, true);
	byte[] file1_name = System.Text.Encoding.UTF8.GetBytes(file);
	files.Put(file1_name, fs.GetSDFObj());
	fs.GetSDFObj().PutText("Desc", desc);

	Obj collection = doc.GetRoot().FindObj("Collection");
	if (collection == null) collection = doc.GetRoot().PutDict("Collection");

	// Manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.PutName("View", "T");
}
PDFDoc doc = new PDFDoc();
AddPackage(doc, filename, "PDF");
AddPackage(doc, imagename, "Image");
```

{% endcode %}
{% endtab %}

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

```cpp
void AddPackage(PDFDoc& doc, string file, const char* desc)
{
	NameTree files = NameTree::Create(doc, "EmbeddedFiles");
	FileSpec fs = FileSpec::Create(doc, file.c_str(), true);
	files.Put((UChar*)file.c_str(), int(file.size()), fs.GetSDFObj());
	fs.SetDesc(desc);

	Obj collection = doc.GetRoot().FindObj("Collection");
	if (!collection) collection = doc.GetRoot().PutDict("Collection");

	// You could here manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.PutName("View", "T");
}
PDFDoc doc;
AddPackage(doc, filename, "PDF");
AddPackage(doc, imagename, "Image");
```

{% endcode %}
{% endtab %}

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

```go
func AddPackage(doc PDFDoc, file string, desc string){
	files := NameTreeCreate(doc.GetSDFDoc(), "EmbeddedFiles")
	fs := FileSpecCreate(doc.GetSDFDoc(), file, true)
	key := make([]byte, len(file))
	for i := 0; i < len(file); i++{
			key[i] = file[i]
			//fmt.Println(file[i])
	}
	files.Put(&key[0], len(key), fs.GetSDFObj())
	fs.SetDesc(desc)

	collection := doc.GetRoot().FindObj("Collection")
	if collection.GetMp_obj().Swigcptr() == 0{
			collection = doc.GetRoot().PutDict("Collection")
	}

	// You could here manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.PutName("View", "T");
}
doc := NewPDFDoc()
AddPackage(doc, filename, "PDF")
AddPackage(doc, imagename, "Image")
```

{% endcode %}
{% endtab %}

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

```java
void addPackage(PDFDoc doc, String file, String desc) throws PDFNetException {
	NameTree files = NameTree.create(doc.getSDFDoc(), "EmbeddedFiles");
	FileSpec fs = FileSpec.create(doc, file, true);
	files.put(file.getBytes(), fs.getSDFObj());
	fs.getSDFObj().putText("Desc", desc);

	Obj collection = doc.getRoot().findObj("Collection");
	if (collection == null) collection = doc.getRoot().putDict("Collection");

	// You could here manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.putName("View", "T");
}
PDFDoc doc = new PDFDoc();
AddPackage(doc, filename, "PDF");
AddPackage(doc, imagename, "Image");
```

{% endcode %}
{% endtab %}

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

```js
async function AddPackage(doc, file, desc) {
	const files = await PDFNet.NameTree.create(doc.getSDFDoc(), "EmbeddedFiles");
	const fs = await PDFNet.FileSpec.create(doc, file, true);
	var key = new TextEncoder("utf-8").encode(file);
	files.put(key, fs.getSDFObj());
	fs.getSDFObj().putText("Desc", desc);

	var collection = doc.getRoot().findObj("Collection");
	if (!collection) collection = doc.getRoot().putDict("Collection");

	// You could here manipulate any entry in the Collection dictionary.
		// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.putName("View", "T");
}

async function main() {
	var doc = await PDFNet.PDFDoc.create();
	await AddPackage(doc, filename, "PDF");
	await AddPackage(doc, imagename, "Image");
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

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

```kotlin
@Throws(PDFNetException::class)
fun addPackage(doc: PDFDoc, file: String, desc: String) {
	val files = NameTree.create(doc.sdfDoc, "EmbeddedFiles")
	val fs = FileSpec.create(doc, file, true)
	files.put(file.toByteArray(), fs.sdfObj)
	fs.sdfObj.putText("Desc", desc)

	var collection: Obj? = doc.root.findObj("Collection")
	if (collection == null) collection = doc.root.putDict("Collection")

	// You could here manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection!!.putName("View", "T")
}
val doc = PDFDoc()
AddPackage(doc, filename, "PDF")
AddPackage(doc, imagename, "Image")
```

{% endcode %}
{% endtab %}

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

```objc
void AddPackage(PTPDFDoc *doc, NSString *file, NSString* desc)
{
	PTNameTree *files = [PTNameTree Create: [doc GetSDFDoc] name: @"EmbeddedFiles"];
    PTFileSpec *fs = [PTFileSpec Create: [doc GetSDFDoc] path: file embed: true];
	[files Put: [file dataUsingEncoding: NSUTF8StringEncoding] key_sz:(int)file.length value: [fs GetSDFObj]];
	[fs SetDesc: desc];

	PTObj * collection = [[doc GetRoot] FindObj: @"Collection"];
	if (!collection) collection = [[doc GetRoot] PutDict: @"Collection"];

	// You could here manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	[collection PutName: @"View" name: @"T"];
}
PTPDFDoc *doc = [[PTPDFDoc alloc] init];
AddPackage(doc, filename, @"PDF");
AddPackage(doc, imagename, @"Image");
```

{% endcode %}
{% endtab %}

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

```swift
func AddPackage(doc: PTPDFDoc, file: String, desc: String) {
    let files: PTNameTree = PTNameTree.create(doc.getSDFDoc(), name: "EmbeddedFiles")
    let fs: PTFileSpec = PTFileSpec.create(doc.getSDFDoc(), path: file, embed: true)
    let data: Data! = file.data(using: .utf8)
    files.put(data, key_sz: Int32(data.count), value: fs.getSDFObj())
    fs.setDesc(desc)

    let collection: PTObj
    if let optCollection: PTObj = doc.getRoot().find("Collection") {
        collection = optCollection
    } else {
        collection = doc.getRoot().putDict("Collection")
    }

    // You could here manipulate any entry in the Collection dictionary.
    // For example, the following line sets the tile mode for initial view mode
    // Please refer to section '2.3.5 Collections' in PDF Reference for details.
    collection.putName("View", name: "T")
}
let doc: PTPDFDoc = PTPDFDoc()
AddPackage(doc: doc, file: filename, desc: "PDF")
AddPackage(doc: doc, file: imagename, desc: "Image")
```

{% endcode %}
{% endtab %}

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

```php
function AddPackage($doc, $file, $desc)
{
	$files = NameTree::Create($doc->GetSDFDoc(), "EmbeddedFiles");
	$fs = FileSpec::Create($doc->GetSDFDoc(), $file, true);
	$files->Put($file, strlen($file), $fs->GetSDFObj());
	$fs->SetDesc($desc);

	$collection = $doc->GetRoot()->FindObj("Collection");
	if (!$collection) $collection = $doc->GetRoot()->PutDict("Collection");

	// You could here manipulate any entry in the Collection dictionary.
	// For example, the following line sets the tile mode for initial view mode
	// Please refer to section '2.3.5 Collections' in PDF Reference for details.
	$collection->PutName("View", "T");
}
$doc = new PDFDoc();
AddPackage($doc, $filename, "PDF");
AddPackage($doc, $imagename, "Image");
```

{% endcode %}
{% endtab %}

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

```python
def AddPackage(doc, file, desc):
    files = NameTree.Create(doc.GetSDFDoc(), "EmbeddedFiles")
    fs = FileSpec.Create(doc.GetSDFDoc(), file, True)
    key = bytearray(file, "utf-8")
    files.Put(key, len(key), fs.GetSDFObj())
    fs.SetDesc(desc)

    collection = doc.GetRoot().FindObj("Collection")
    if collection is None:
        collection = doc.GetRoot().PutDict("Collection")

    # You could here manipulate any entry in the Collection dictionary.
    # For example, the following line sets the tile mode for initial view mode
    # Please refer to section '2.3.5 Collections' in PDF Reference for details.
    collection.PutName("View", "T")
doc = PDFDoc()
AddPackage(doc, filename, "PDF")
AddPackage(doc, imagename, "Image")
```

{% endcode %}
{% endtab %}

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

```ruby
def AddPackage(doc, file, desc)
	files = NameTree.Create(doc.GetSDFDoc, "EmbeddedFiles")
	fs = FileSpec.Create(doc.GetSDFDoc, file, true)
	files.Put(file, file.length, fs.GetSDFObj)
	fs.SetDesc(desc)

	collection = doc.GetRoot.FindObj("Collection")
	if collection.nil?
		collection = doc.GetRoot.PutDict("Collection")
	end

	# You could here manipulate any entry in the Collection dictionary.
	# For example, the following line sets the tile mode for initial view mode
	# Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.PutName("View", "T")
end
doc = PDFDoc.new
AddPackage(doc, filename, "PDF")
AddPackage(doc, imagename, "Image")
```

{% endcode %}
{% endtab %}

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

```vb
Sub AddPackage(ByRef doc As PDFDoc, ByVal file As String, ByVal desc As String)
	Dim files As NameTree = NameTree.Create(doc.GetSDFDoc(), "EmbeddedFiles")
	Dim fs As FileSpec = FileSpec.Create(doc, file, True)
	files.Put(System.Text.Encoding.UTF8.GetBytes(file), fs.GetSDFObj())
	fs.GetSDFObj().PutText("Desc", desc)

	Dim collection As Obj = doc.GetRoot().FindObj("Collection")
	If collection = Nothing then
		collection = doc.GetRoot().PutDict("Collection")
	End If

	' Manipulate any entry in the Collection dictionary.
    ' For example, the following line sets the tile mode for initial view mode
    ' Please refer to section '2.3.5 Collections' in PDF Reference for details.
	collection.PutName("View", "T")
End Sub
Dim doc As PDFDoc = New PDFDoc()
AddPackage(doc, filename, "PDF")
AddPackage(doc, imagename, "Image")
```

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

[PDF packages (portfolios)](/core/get-started/samples/pdfpackagetest.md) Full code sample which illustrates how to create, extract, and manipulate PDF Packages (also known as PDF Portfolios). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/portfolio/create.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
