pdf_png
¶
copy_photo_next_to_typst_file(rendercv_model, typst_path)
¶
Copy CV photo to Typst file directory for compilation.
Why
Typst compiler resolves image paths relative to source file location. Copying photo ensures compilation succeeds regardless of original photo location.
Parameters:
-
rendercv_model(RenderCVModel) –CV model containing photo path.
-
typst_path(Path) –Path to Typst source file.
Source code in src/rendercv/renderer/pdf_png.py
generate_pdf(rendercv_model, typst_path)
¶
Compile Typst source to PDF using typst-py compiler.
Why
PDF is the primary output format for CVs. Typst compilation produces high-quality PDFs with proper fonts, layout, and typography from the intermediate Typst markup.
Parameters:
-
rendercv_model(RenderCVModel) –CV model for path resolution and photo handling.
-
typst_path(Path | None) –Path to Typst source file to compile.
Returns:
-
Path | None–Path to generated PDF file, or None if generation disabled.
Source code in src/rendercv/renderer/pdf_png.py
generate_png(rendercv_model, typst_path)
¶
Compile Typst source to PNG images using typst-py compiler.
Why
PNG format enables CV preview in web applications and README files. Multi-page CVs produce multiple PNG files with sequential numbering.
Parameters:
-
rendercv_model(RenderCVModel) –CV model for path resolution and photo handling.
-
typst_path(Path | None) –Path to Typst source file to compile.
Returns:
-
list[Path] | None–List of paths to generated PNG files, or None if generation disabled.
Source code in src/rendercv/renderer/pdf_png.py
get_package_path()
cached
¶
Set up local Typst package resolution from bundled Typst packages.
Why
Bundled Typst packages (rendercv, fontawesome) are shipped inside the Python package so that PDF compilation works without downloading from Typst Universe. The Typst compiler expects packages in a directory structure of preview/{name}/{version}/, so this creates a temporary directory with that layout.
Returns:
-
Path–Path to temporary package cache directory.
Source code in src/rendercv/renderer/pdf_png.py
get_typst_compiler(input_file_path, root)
cached
¶
Create cached Typst compiler with font paths configured.
Why
Compiler initialization is expensive. Caching enables reuse across all compilations. The source file is passed per compile() call, so the compiler survives output filename changes (e.g., when cv.name changes). Font paths include package fonts and optional user fonts from input file directory.
Parameters:
-
input_file_path(Path | None) –Original input file path for relative font resolution.
-
root(Path) –Root directory for Typst project. Must contain the input file.
Returns:
-
Compiler–Configured Typst compiler instance.
Source code in src/rendercv/renderer/pdf_png.py
install_bundled_typst_package(bundled_path, package_name, temp_dir, typ_files)
¶
Copy a bundled Typst package into the temporary package cache.
Why
The Typst compiler expects packages in a directory structure of preview/{name}/{version}/. This copies the required files from a bundled package into that layout.
Parameters:
-
bundled_path(Path) –Path to the bundled package directory.
-
package_name(str) –Name of the Typst package (used in directory structure).
-
temp_dir(Path) –Root of the temporary package cache.
-
typ_files(list[str]) –List of .typ filenames to copy alongside typst.toml.
Source code in src/rendercv/renderer/pdf_png.py
read_version_from_typst_toml(typst_toml_path)
¶
Read the version field from a typst.toml file.
Why
Multiple bundled Typst packages need their version extracted for directory layout. Centralizes the parsing logic.
Parameters:
-
typst_toml_path(Path) –Path to the typst.toml file.
Returns:
-
str–The version string.