Skip to main content

compile_theme

Function compile_theme 

Source
pub fn compile_theme(
    theme: &Theme,
    data: &Value,
) -> Result<Vec<u8>, RenderError>
Expand description

Compile a Theme bundle to PDF bytes against a JSON Resume value.

Every (virtual_path, bytes) pair in theme.files is registered in the World. Typst starts compilation from theme.entrypoint; relative imports inside theme sources resolve against the entrypoint’s virtual directory, which is why it’s the caller’s responsibility to register all referenced files under a shared prefix (see crate::theme for the convention).

On success, the returned vector starts with the PDF magic bytes %PDF-. On failure, returns RenderError with one or more diagnostics describing what the compiler rejected — e.g. a reference to a field the supplied data does not carry, or a @preview/... import that the World refuses to resolve (CONSTITUTION §6.1).