Skip to content

Commit 5cfb964

Browse files
committed
Update examples - add example of custom locations
1 parent 821cefb commit 5cfb964

10 files changed

Lines changed: 45 additions & 7 deletions

File tree

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@ kept if you specify `--debug`.
5959

6060
## Examples
6161

62-
For working examples, see the [examples](examples) directory.<br> Create all PDFs with:
62+
For working examples, see the [examples](examples) directory:
63+
64+
- [minimal](examples/minimal) - Basic usage
65+
- [regular](examples/regular) - Standard features
66+
- [variants](examples/variants) - Document variants
67+
- [custom_locations](examples/custom_locations) - Custom file/directory locations
68+
- [custom_processing](examples/custom_processing) - Custom processing with Python
69+
70+
Create all PDFs with:
6371

6472
```bash
65-
pdfbaker bake examples/examples.yml
73+
pdfbaker bake examples/examples.yaml
6674
```
6775

6876
## Documentation
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: "Custom Location Example"
2+
description: "This page uses custom directory structure"
3+
template: "../other_templates/custom_page.svg.j2"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<svg width="210mm" height="297mm" viewBox="0 0 210 297" version="1.1">
3+
<text x="105" y="50" text-anchor="middle" font-size="20">{{ title }}</text>
4+
<text x="105" y="80" text-anchor="middle" font-size="14">{{ description }}</text>
5+
</svg>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: "Custom Locations Example"
2+
filename: "custom_locations_custom"
3+
pages:
4+
# Simple notation - uses conventional location (pages/standard_page.yaml)
5+
- "standard_page"
6+
# Path notation - uses custom location
7+
- "../other_pages/custom_page.yaml"
8+
# Custom images directory name and location
9+
images_dir: "../your_images"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
title: "Content Page"
2+
description: "This document is located in a nested directory structure, demonstrating how pdfbaker can handle documents located anywhere in your filesystem."
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
title: "Custom Locations Example"
2+
subtitle: "Mixing conventional and custom locations"
3+
template: "templates/intro.svg.j2"
4+
# Uses conventional location (templates/intro.svg.j2)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: "Standard Location Example"
2+
subtitle: "This page uses conventional directory structure"
3+
template: "standard_page.svg.j2"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<svg width="210mm" height="297mm" viewBox="0 0 210 297" version="1.1">
3+
<text x="105" y="50" text-anchor="middle" font-size="20">{{ title }}</text>
4+
<text x="105" y="80" text-anchor="middle" font-size="14">{{ subtitle }}</text>
5+
</svg>
23.5 KB
Loading

examples/custom_processing/bake.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from datetime import datetime
77

88
from pdfbaker.document import PDFBakerDocument
9-
from pdfbaker.errors import PDFBakeError
9+
from pdfbaker.errors import PDFBakerError
1010

1111

1212
def process_document(document: PDFBakerDocument) -> None:
@@ -30,8 +30,7 @@ def process_document(document: PDFBakerDocument) -> None:
3030
"fetched_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
3131
"image_data": image_data,
3232
}
33-
34-
# Process as usual
35-
return document.process()
3633
except Exception as exc:
37-
raise PDFBakeError(f"Failed to process XKCD example: {exc}") from exc
34+
raise PDFBakerError(f"Failed to process XKCD example: {exc}") from exc
35+
36+
return document.process()

0 commit comments

Comments
 (0)