Frequently Asked Questions
Licensing and Open Source
What is the license for Aspose.PDF FOSS for Go?
Aspose.PDF FOSS for Go is released under the MIT License. The full license text is included in the repository at github.com/aspose-pdf-foss/aspose-pdf-foss-for-go. No registration, activation file, or runtime key is required.
Can I use Aspose.PDF FOSS for Go in a commercial product?
Yes. The MIT license permits unrestricted commercial use, modification, distribution, and private use. You must include the copyright notice and MIT license text in all copies or substantial portions of the software.
Is there an enterprise version?
Aspose.PDF FOSS is the open-source, MIT-licensed edition. A separate commercial Aspose.PDF product is available at products.aspose.com/pdf/ with enterprise support, extended format coverage, and cloud integration.
Installation and Requirements
How do I install Aspose.PDF FOSS for Go?
Add the module to your Go project:
go get github.com/aspose-pdf-foss/aspose-pdf-foss-for-goImport it with an alias in your source files:
import pdf "github.com/aspose-pdf-foss/aspose-pdf-foss-for-go"What Go version is required?
Go 1.24 or later is required. Verify your version with go version.
Are there native or system library dependencies?
No. Aspose.PDF FOSS for Go is a pure-Go implementation with no C, C++, or CGo dependencies. It does not require any system libraries, PDF viewers, or external tools.
API Usage
How do I open an existing PDF?
Use pdf.Open for standard PDFs and pdf.OpenWithPassword for password-protected files:
doc, err := pdf.Open("document.pdf")
if err != nil {
return err
}
defer doc.Close()How do I split a PDF into individual pages?
Document.Split returns a []*Document, one per page:
doc, _ := pdf.Open("report.pdf")
pages, _ := doc.Split()
for i, p := range pages {
p.Save(fmt.Sprintf("page_%03d.pdf", i+1))
}How do I merge multiple PDFs?
Document.Append merges a source document in-place:
base, _ := pdf.Open("part1.pdf")
part2, _ := pdf.Open("part2.pdf")
base.Append(part2)
base.Save("combined.pdf")How do I fill an AcroForm field?
Use Document.Form().Field(name) and assert the concrete type:
doc, _ := pdf.Open("form.pdf")
text := doc.Form().Field("customer_name").(*pdf.TextBoxField)
text.SetValue("Jane Doe")
check := doc.Form().Field("agree").(*pdf.CheckboxField)
check.SetChecked(true)
doc.Save("form_filled.pdf")Supported field types: TextBoxField, CheckboxField, RadioButtonField,
ComboBoxField, ListBoxField, ButtonField.
How do I add bookmarks?
Create an OutlineItemCollection and set a Destination:
doc, _ := pdf.Open("manual.pdf")
page, _ := doc.Page(1)
bm := pdf.NewOutlineItemCollection(doc)
bm.SetTitle("Chapter 1")
bm.SetDestination(pdf.NewDestinationXYZ(page, 0, 800, 1.0))
doc.Outlines().Add(bm)
doc.Save("manual_with_bookmarks.pdf")Security and Encryption
How do I password-protect a PDF?
Use Document.SetEncryption with EncryptionOptions:
doc, _ := pdf.Open("doc.pdf")
doc.SetEncryption(pdf.EncryptionOptions{
UserPassword: "userpass",
OwnerPassword: "ownerpass",
Permissions: &pdf.Permissions{AllowPrint: true, AllowCopy: false},
})
doc.Save("doc_protected.pdf")Which encryption algorithms are supported?
Three algorithms are available via EncryptionOptions.Algorithm:
| Algorithm | Constant | Standard |
|---|---|---|
| AES-128 | EncryptionAlgAES128 (default) | ISO 32000-1 |
| AES-256 | EncryptionAlgAES256 | ISO 32000-2 (PDF 2.0 output) |
| RC4-128 | EncryptionAlgRC4_128 | Legacy |
How do I open a password-protected file?
doc, err := pdf.OpenWithPassword("protected.pdf", "userpass")How do I remove encryption from a PDF?
doc, _ := pdf.OpenWithPassword("protected.pdf", "userpass")
doc.RemoveEncryption()
doc.Save("decrypted.pdf")Known Limitations
Are all PDF features supported?
The library covers the most common document management operations: open, create, save, split, merge, page extraction, encryption, AcroForms, tables, bookmarks, and annotations. Advanced features such as digital signatures, 3D content, and PDF/A conversion may not be fully implemented in the current release. Check the repository README for the current feature status.
What happens if I use a field type assertion that does not match?
A type assertion on Field that does not match the actual field type will panic.
Use pdf.FieldType(f) to inspect the type before asserting, or use a type switch:
for _, f := range doc.Form().Fields() {
switch v := f.(type) {
case *pdf.TextBoxField:
fmt.Println("text:", v.Value())
case *pdf.CheckboxField:
fmt.Println("checked:", v.Checked())
}
}