Skip to content

Portfolio

huzpsb edited this page Nov 8, 2026 · 2 revisions

Portfolio

Manage portfolio entries — PDF collections/packages (a.k.a. PDF portfolios) that present attached files in a dedicated viewer UI, unlike plain Attachments.

Command line

hspdf portfolio list in.pdf
hspdf portfolio add in.pdf contract.pdf                     # add entry
hspdf portfolio add in.pdf "intro.mp4, Product intro"       # with description
hspdf portfolio extract in.pdf outDir
hspdf portfolio remove in.pdf contract.pdf

Pipeline:

cat package.pdf | hspdf portfolio add - contract.pdf > package-with-contract.pdf

Go API

package main

import (
	"context"

	"github.com/huzpsb/hspdf/pkg/api"
	"github.com/huzpsb/hspdf/pkg/pdfcpu/model"
)

func main() {
	ctx := context.Background()
	conf := model.NewDefaultConfiguration()

	// coll=true turns attachments into portfolio entries
	err := api.AddAttachmentsFile(ctx, "in.pdf", "out.pdf", []string{"contract.pdf"}, true, conf)
	if err != nil {
		panic(err)
	}

	// Inventory (same reader as attachments; portfolios carry a collection)
	_ = api.ExtractAttachmentsFile(ctx, "in.pdf", "./entries", nil, conf)
}

Portfolio entries and attachments share the same underlying embedded-file machinery — add/extract/remove map to api.AddAttachmentsFile(..., coll=true, ...), api.ExtractAttachmentsFile and api.RemoveAttachmentsFile.

Clone this wiki locally