Skip to content

Felixmil/quarto-envelope

Repository files navigation

Envelope Format

A Quarto extension for generating print-ready envelope PDFs programmatically using Typst. Supports common envelope sizes with configurable sender and recipient addresses.

Installing

quarto use template felixmil/quarto-envelope

This will install the extension and create an example template.qmd file you can use as a starting point.

Using

Set the format to envelope-typst in your document's YAML front matter and provide the sender and recipient addresses as arrays:

---
format:
  envelope-typst:
    size: C6
sender:
  - "Jean Dupont"
  - "12 rue de la Paix"
  - "75001 Paris"
recipient:
  - "Marie Martin"
  - "45 avenue du Prado"
  - "13008 Marseille"
---

Then render with:

quarto render template.qmd

Here's the output:

Here is another example with envelope_type: DL:

Options

sender and recipient are top-level metadata keys (not under format:):

Key Description
sender Sender address lines (array)
recipient Recipient address lines (array)

Format options go under format: envelope-typst::

Option Description Default
size Envelope size (see supported types below) DL
sender-fontsize Font size for the sender address 11pt
recipient-fontsize Font size for the recipient address 14pt
sender-width Width of the sender block 30%
recipient-width Width of the recipient block 40%
recipient-shift-x Horizontal offset for the recipient block -10%
recipient-shift-y Vertical offset for the recipient block 10%

Supported Envelope Types

You can specify size as a named size string or as a custom "HxW" string in millimeters.

Named sizes

Type Dimensions (H × W)
C4 229 × 324 mm
C5 162 × 229 mm
C6 114 × 162 mm
DL 110 × 220 mm
B4 250 × 353 mm
B5 176 × 250 mm
#10 105 × 241 mm
#9 98 × 225 mm
Monarch 98 × 190 mm
A2 111 × 146 mm

Custom size

Pass a "HxW" string in mm:

format:
  envelope-typst:
    size: 125x185

Batch Rendering

To generate one envelope PDF per recipient from a CSV file, use the included render_envelopes.R script. It renders template-batch.qmd — a minimal template with no hardcoded addresses — injecting sender and recipient data at render time via --metadata-file.

CSV format

Create a CSV file with the following columns:

first_name,last_name,adresse,city,zip
Paul,Durant,12 rue de la Paix,Paris,75001
Jeanne,Durand,45 avenue des Fleurs,Lyon,69002

A sample file is provided at data/recipients.csv.

Running the script

Edit the sender variable at the top of render_envelopes.R, then run:

source("render_envelopes.R")

Or from the terminal:

Rscript render_envelopes.R

One PDF per recipient will be written to output/, named envelope_<first>_<last>.pdf.

How it works

The script writes a temporary YAML file for each recipient containing the sender and recipient address arrays, then calls:

quarto render template-batch.qmd --output <name>.pdf --metadata-file <tmp>.yaml

Note: sender and recipient must not be defined in the front matter of template-batch.qmd, as document front matter takes precedence over --metadata-file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors