Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
fb1a376
Add import/export examples for PDF form data in facades section
andruhovski Feb 8, 2026
0aebf8e
Added samples for import/export Form data
andruhovski Feb 8, 2026
862b5fc
Add sample form outputs in multiple formats
andruhovski Feb 18, 2026
a524ee9
Add examples for exporting and importing PDF form data in facades sec…
andruhovski Feb 18, 2026
0d10cbc
Add examples for filling various PDF form fields in facades section
andruhovski Feb 19, 2026
4236679
Add examples for filling various PDF form fields in facades section
andruhovski Feb 19, 2026
8e1090c
Add examples for flattening and renaming PDF form fields in facades s…
andruhovski Feb 19, 2026
4003aea
Add example for filling fields by name and value in facades section
andruhovski Feb 19, 2026
9a05500
Add examples for reading and inspecting PDF form data in facades section
andruhovski Feb 19, 2026
e902b92
Add examples for managing PDF form fields and retrieving field inform…
andruhovski Feb 19, 2026
c120053
Refactor form editor examples and remove deprecated scripts
AnHolub Feb 23, 2026
6a4cc5f
Remove outdated examples for PDF file editing operations including de…
AnHolub Mar 3, 2026
fa726b9
Add examples for PDF form field management, content editing, page ope…
AnHolub Mar 3, 2026
118279f
Enhance form editor examples by adding input/output parameters and im…
andruhovski Mar 4, 2026
9365b42
Added sample data
andruhovski Mar 4, 2026
f9c9332
Add examples for managing button fields, deleting annotations, and re…
andruhovski Mar 4, 2026
f3edb37
Merge branch '4-add-examples-in-facades-section' of https://github.co…
andruhovski Mar 4, 2026
5e5aad1
Add examples for PDF page management, layout, and splitting operations
AnHolub Mar 4, 2026
260e869
Merge branch '4-add-examples-in-facades-section' of https://github.co…
AnHolub Mar 4, 2026
5bbdce2
Add sample data
andruhovski Mar 4, 2026
ab022fa
Refactor run_all_examples function to simplify argument handling and …
andruhovski Mar 4, 2026
e6ef073
Add examples for adding free text, text, and line annotations to PDF …
andruhovski Mar 4, 2026
635d02d
Remove deprecated annotation examples from the facades section
andruhovski Mar 4, 2026
ac23712
Merge branch '4-add-examples-in-facades-section' of https://github.co…
andruhovski Mar 4, 2026
31b49a7
Add examples for PDF manipulation in facades section
andruhovski Mar 4, 2026
ae29d69
Added sample data
andruhovski Mar 4, 2026
5901565
Add examples for concatenating and splitting PDF documents in facades…
andruhovski Mar 5, 2026
86f2149
Added sample data
andruhovski Mar 5, 2026
bb257a3
Add PDF metadata examples and remove outdated scripts
andruhovski Mar 9, 2026
d0f29eb
Added samples
andruhovski Mar 10, 2026
f53c7ab
Refactor fill_fields_by_name_and_value to return filled PDF as stream
andruhovski Mar 12, 2026
cd3f411
Add examples for creating various form fields in PDF documents
andruhovski Mar 12, 2026
5019c04
Refactor remove_field_script and set_submit_flag functions for improv…
andruhovski Mar 12, 2026
1b34e28
Add sample PDF for the FormEditor examples
andruhovski Mar 12, 2026
23bfafc
update the security section
AnHolub Mar 17, 2026
b244f31
Merge branch '4-add-examples-in-facades-section' of https://github.co…
AnHolub Mar 17, 2026
e78f614
minor fix
AnHolub Mar 17, 2026
aad5aea
Add examples for various annotations and document actions in PDF
andruhovski Mar 17, 2026
3c8345d
Merge branch '4-add-examples-in-facades-section' of https://github.co…
andruhovski Mar 17, 2026
e78a857
Remove unnecessary PDF file generated during testing to clean up the …
andruhovski Mar 17, 2026
6fbbeb8
Add .vscode to .gitignore to exclude Visual Studio Code settings
andruhovski Mar 18, 2026
604f68d
Remove outdated examples from the facades section
andruhovski Mar 18, 2026
abd9c22
Enhance attachment examples in facades section with detailed annotati…
andruhovski Mar 18, 2026
e305a01
Add examples for annotations, attachments, and viewer preferences in …
andruhovski Mar 19, 2026
07ab510
Updated sample data
andruhovski Mar 19, 2026
e026409
Remove outdated examples and add new functionalities for PDF signatur…
AnHolub Apr 1, 2026
9ad629b
add examples
AnHolub Apr 1, 2026
9d53fb8
add samples
AnHolub Apr 1, 2026
c166d95
Update certificate management examples and enhance success/error mess…
andruhovski Apr 1, 2026
d9da29f
Add new PDF examples for facades section and remove outdated files
andruhovski Apr 1, 2026
16b3de6
Add examples for managing and filling PDF form fields
andruhovski Apr 1, 2026
1c36e01
Add examples for PDF signature verification, usage rights management,…
andruhovski Apr 1, 2026
ddd0be0
Update sample data location
andruhovski Apr 1, 2026
61c246e
Add configuration file for Codex settings and project instructions
andruhovski Apr 1, 2026
a939f76
Add example specifications for various PDF operations
andruhovski Apr 1, 2026
0776585
Add examples and guidelines for using facade APIs in PDF operations
andruhovski Apr 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .codex/SKILLS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Local Codex Skills

This repository now uses small, task-focused skills instead of one monolithic skill document.

## Skills

- `pdf-operations`
- Purpose: Aspose.PDF operation patterns, API hints, and example behavior rules.
- File: `.codex/skills/pdf-operations/SKILL.md`
- `code-style`
- Purpose: Shared formatting, file layout, naming, path, and error-handling conventions.
- File: `.codex/skills/code-style/SKILL.md`
- `spec-generator`
- Purpose: Generate or refresh machine-readable example specs and scaffold new example files.
- File: `.codex/skills/spec-generator/SKILL.md`

## Suggested Combinations

- New example implementation:
- `pdf-operations` + `code-style`
- Refactor or normalize an existing example:
- `pdf-operations` + `code-style`
- Refresh generated repository metadata/specs:
- `spec-generator`
- Add a new example and keep generated specs in sync:
- `pdf-operations` + `code-style` + `spec-generator`

## Scripts

- `python scripts/generate_example_specs.py`
- Scans `examples/` and refreshes generated spec artifacts under `specs/examples/`
- `python scripts/generate_example_stub.py --category <category> --name <slug> --operation <function_name>`
- Scaffolds a new example file using the repo's standard template

## Generated Artifacts

- `specs/examples/index.json`
- `specs/examples/index.md`

Treat those files as generated outputs. Re-run the generator after adding or materially changing example modules.
29 changes: 29 additions & 0 deletions .codex/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ~/.codex/config.yaml

# --- Core Codex Settings ---
model: gpt-5.3
approval_mode: auto-edit
notify: true

# --- Execution Behavior ---
fullAutoErrorMode: ask-user # ask-user | ignore-and-continue

# --- Project Instructions ---
instructions: |
You are working in a repository of Python examples for Aspose.PDF for Python via .NET.

Prefer the narrowest applicable local skill from `.codex/skills/`:
- `pdf-operations` for Aspose.PDF API usage and example behavior
- `code-style` for structure, naming, path handling, and output conventions
- `spec-generator` for generating or refreshing repository example specs

Global repository rules:
- Preserve the established example architecture under `examples/`
- Reuse `examples/config.py` for `set_license(...)` and `initialize_data_dir(...)`
- Do not add new dependencies beyond the repo's current Python requirements unless explicitly requested
- Prefer repo-owned automation in `scripts/` over ad-hoc one-off generation logic
- When examples are added or materially changed, refresh the generated spec artifacts with:
`python scripts/generate_example_specs.py`
- When scaffolding a new example, prefer:
`python scripts/generate_example_stub.py --category <category> --name <slug> --operation <function_name>`
- Keep generated artifacts deterministic and safe to re-run
69 changes: 69 additions & 0 deletions .codex/skills/code-style/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: code-style
description: Apply shared repository style rules for Aspose.PDF Python example files, including structure, naming, path handling, docstrings, status output, and error handling.
metadata:
short-description: Shared style rules for example scripts
version: "1.0"
---

# Code Style

## Use This Skill When

- Creating or refactoring repository example scripts
- Normalizing older examples to the current house style
- Reviewing whether generated code matches repository conventions

## Structure Rules

- Keep the import block simple and consistent
- Always use:
- `from os import path`
- `sys.path.append(path.join(path.dirname(__file__), '..'))`
- Use following snippet in `facades` subfolder examples:
```python
from os import path
import sys

CURRENT_DIR = path.dirname(__file__)
EXAMPLES_DIR = path.abspath(path.join(CURRENT_DIR, "..", ".."))
if EXAMPLES_DIR not in sys.path:
sys.path.insert(0, EXAMPLES_DIR)
```
- Import shared helpers from `examples/config.py`
- Preserve `run_all_examples()` as the entrypoint

## Function Rules

- Operation functions must accept file paths as `str`
- Do not pass `Document` objects between functions
- Use descriptive names tied to the actual action
- Keep one function responsible for one operation

## Path Rules

- Use `path.join(...)` for repository-local paths
- Do not hardcode absolute paths
- Use `initialize_data_dir(...)` instead of hand-rolling sample-data locations

## Error Handling And Output

- Wrap each example run in `try/except`
- Do not stop the full example run because one case failed
- Preserve the repository's success/failure markers:
- `✅ Success`
- `❌ Failed`

## Documentation

- Add or preserve concise docstrings on public example functions
- Prefer docstrings with `Args` and `Returns` when the function is non-trivial
- Keep comments brief and useful

## Anti-Patterns

- Hardcoded file system paths
- Breaking `run_all_examples()`
- Removing status prints
- Adding dependencies not already used by the repo
- Large architectural rewrites for narrow example changes
194 changes: 194 additions & 0 deletions .codex/skills/pdf-operations/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
---
name: pdf-operations
description: Implement or update Aspose.PDF for Python via .NET example logic, including opening, saving, merging, splitting, protecting, converting, and related document operations.
metadata:
short-description: Aspose.PDF example operation guidance
version: "1.0"
---

# PDF Operations

## Use This Skill When

- Creating a new example script for a PDF feature
- Updating example logic that touches Aspose.PDF APIs
- Translating a request like merge, split, encrypt, convert, annotate, extract, or optimize into repository code

## Required Behavior

- Operate on file paths, not shared `Document` objects passed between functions
- Keep one public operation function focused on one concrete behavior
- Preserve `run_all_examples()` as the execution entrypoint
- Keep examples runnable in evaluation mode when no license is supplied

## Standard Structure

Every example should align with this flow:

1. Import `aspose.pdf as ap`
2. Append the parent examples directory with:
`sys.path.append(path.join(path.dirname(__file__), '..'))`
3. Import `set_license` and `initialize_data_dir` from `config`
4. Implement one or more operation functions accepting string paths
5. Implement `run_all_examples(data_dir=None, license_path=None)`
6. Call `set_license(...)` and `initialize_data_dir(...)`
7. Execute examples with per-example `try/except`

For nested example folders, adjust the shared-config import path to match the real directory depth. For example, files under `examples/facades/pdf_content_editor/` can use:

```python
CURRENT_DIR = path.dirname(__file__)
EXAMPLES_DIR = path.abspath(path.join(CURRENT_DIR, "..", ".."))
if EXAMPLES_DIR not in sys.path:
sys.path.insert(0, EXAMPLES_DIR)

from config import set_license, initialize_data_dir
```

## API Reference

- Open document:
- `ap.Document(path)`
- `ap.Document(path, password)`
- Save document:
- `document.save(path)`
- Merge:
- `doc1.pages.add(doc2.pages)`
- Encrypt:
- `document.encrypt(user_pwd, owner_pwd, privileges, algorithm, False)`
- Convert:
- `document.convert(log_path, ap.PdfFormat.PDF_X_3, ap.ConvertErrorAction.DELETE)`

## Facades

Use facade APIs when the repository already demonstrates a task through `aspose.pdf.facades` rather than the core `Document` API. In these examples, the operation function should still accept file paths, but the implementation can create and bind a facade object internally.

### Shared Facade Pattern

For content-editor style examples:

```python
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd

def operation_name(infile, outfile):
content_editor = pdf_facades.PdfContentEditor()
content_editor.bind_pdf(infile)
# perform facade operation
content_editor.save(outfile)
```

### Facade Rules

- Keep facade object creation inside the operation function
- Bind with `bind_pdf(infile)` before mutating content
- Save with the facade object after the operation is complete
- Use `aspose.pydrawing` geometry and colors when the facade API requires rectangles or color values
- Preserve one function per concrete operation even when multiple operations share the same facade class

### PdfContentEditor Examples

Text annotation:

```python
def add_text_annotation(infile, outfile):
content_editor = pdf_facades.PdfContentEditor()
content_editor.bind_pdf(infile)
content_editor.create_text(
apd.Rectangle(100, 400, 50, 50),
"Text Annotation",
"This is a text annotation",
True,
"Insert",
1,
)
content_editor.save(outfile)
```

Free text annotation:

```python
def add_free_text_annotation(infile, outfile):
content_editor = pdf_facades.PdfContentEditor()
content_editor.bind_pdf(infile)
content_editor.create_free_text(
apd.Rectangle(200, 480, 150, 25),
"This is a free text annotation",
1,
)
content_editor.save(outfile)
```

Caret annotation:

```python
def add_caret_annotation(infile, outfile):
content_editor = pdf_facades.PdfContentEditor()
content_editor.bind_pdf(infile)
content_editor.create_caret(
1,
apd.Rectangle(350, 400, 10, 10),
apd.Rectangle(300, 380, 115, 15),
"P",
"This is a caret annotation",
apd.Color.red,
)
content_editor.save(outfile)
```

Markup annotation variants:

```python
def add_markup_annotation(infile, outfile):
content_editor = pdf_facades.PdfContentEditor()
content_editor.bind_pdf(infile)
content_editor.create_markup(
apd.Rectangle(120, 440, 200, 20),
"This is a highlight annotation",
0,
1,
apd.Color.yellow,
)
content_editor.create_markup(
apd.Rectangle(110, 542, 200, 20),
"This is a underline annotation",
1,
1,
apd.Color.yellow,
)
content_editor.save(outfile)
```

Popup annotation:

```python
def add_popup_annotation(infile, outfile):
content_editor = pdf_facades.PdfContentEditor()
content_editor.bind_pdf(infile)
content_editor.create_popup(
apd.Rectangle(220, 520, 180, 80),
"This is a popup annotation",
True,
1,
)
content_editor.save(outfile)
```

### When To Prefer Facades

- The existing repo examples for that feature already use `aspose.pdf.facades`
- The API is centered on editor-style helpers such as content editing, file security, file info, or signatures
- The operation is naturally modeled as bind -> mutate -> save rather than load `Document` -> traverse object model -> save

## Repository Constraints

- Python 3.7+ source style
- Allowed dependencies are limited to the repo requirements
- Do not introduce a test framework just for examples
- Do not redesign folder structure when a focused example change will do

## Output Expectations

- Generated output names should remain descriptive and stable
- Prefer `{function_name}_out.pdf` when producing a single canonical PDF output
- Status lines should remain easy to scan from the console
44 changes: 44 additions & 0 deletions .codex/skills/spec-generator/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: spec-generator
description: Generate and maintain repository example specs and example scaffolding artifacts for Aspose.PDF for Python via .NET.
metadata:
short-description: Example spec generation workflow
version: "1.0"
---

# Spec Generator

## Use This Skill When

- Refreshing machine-readable metadata for the example catalog
- Generating repo documentation from the current `examples/` tree
- Scaffolding a new example file with the standard repository template
- Keeping Codex-facing specs aligned with the actual source tree

## Pipeline Entry Points

- Refresh generated specs:
- `python scripts/generate_example_specs.py`
- Scaffold a new example:
- `python scripts/generate_example_stub.py --category <category> --name <slug> --operation <function_name>`

## Generated Outputs

- `specs/examples/index.json`
- `specs/examples/index.md`

These artifacts should be deterministic so they can be regenerated after source changes.

## Generator Expectations

- Scan `examples/` recursively
- Ignore generated caches and `examples/config.py`
- Extract stable metadata from Python source
- Preserve sorted output for low-noise diffs
- Fail loudly on invalid Python modules instead of silently producing partial garbage

## Integration Rules

- After adding or materially changing an example module, refresh specs before closing the task
- Prefer updating generator scripts instead of hand-editing generated spec artifacts
- Keep scaffolded examples aligned with the `pdf-operations` and `code-style` skills
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,4 @@ BundleArtifacts/
.cake/*

.nugetapikey
.vscode
Loading