### Generate Sales Report PDF with Nested Data Source: https://context7.com/mfeckie/imprintor/llms.txt This example shows how to generate a PDF report using nested Elixir data structures. All Elixir types are converted to their Typst equivalents, and data is accessed via `sys.inputs.elixir_data`. ```elixir template = """ = Regional Sales Report: #sys.inputs.elixir_data.period #for region in sys.inputs.elixir_data.regions [ == #region.name Region *Total Revenue:* \$#region.total_revenue === Top Products #for product in region.products [ - *#product.name* — \$#product.revenue (#product.units units) ] --- ] *Report prepared by:* #sys.inputs.elixir_data.author """ data = %{ "period" => "H1 2024", "author" => "Finance Team", "regions" => [ %{ "name" => "North", "total_revenue" => 225_000, "products" => [ %{"name" => "Widget Pro", "revenue" => 95_000, "units" => 320}, %{"name" => "Widget Basic", "revenue" => 130_000, "units" => 870} ] }, %{ "name" => "South", "total_revenue" => 187_000, "products" => [ %{"name" => "Gadget X", "revenue" => 112_000, "units" => 210}, %{"name" => "Gadget Y", "revenue" => 75_000, "units" => 430} ] } ] } config = Imprintor.Config.new(template, data) {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) File.write!("regional_sales.pdf", pdf_binary) ``` -------------------------------- ### Typst Variable Substitution Syntax Example Source: https://github.com/mfeckie/imprintor/blob/main/README.md Demonstrates Typst syntax for accessing nested data within a template. Use `sys.inputs.elixir_data` to reference data passed from Elixir. ```typst = Customer Report *Name:* #sys.inputs.elixir_data.customer.name *Email:* #sys.inputs.elixir_data.customer.email == Orders #for order in sys.inputs.elixir_data.orders [ - #order.product: \$#order.total ] ``` -------------------------------- ### Create Imprintor.Config with template only Source: https://context7.com/mfeckie/imprintor/llms.txt Use `Imprintor.Config.new/3` to create a configuration with a Typst template string. This is the minimal configuration. ```elixir config = Imprintor.Config.new("= Hello World\n\nNo variables here.") ``` -------------------------------- ### Create Imprintor.Config with data (string keys) Source: https://context7.com/mfeckie/imprintor/llms.txt Create an `Imprintor.Config` with a Typst template and a map of data. Data keys can be strings and will be accessible in Typst via `sys.inputs.elixir_data`. ```elixir config = Imprintor.Config.new( "= Invoice #sys.inputs.elixir_data.invoice_number\n\n*Customer:* #sys.inputs.elixir_data.customer\n*Due:* #sys.inputs.elixir_data.due_date", %{ "invoice_number" => "INV-0042", "customer" => "Acme Corp", "due_date" => "2024-09-01" } ) ``` -------------------------------- ### Generate QR Code PDF with Typst Package Source: https://context7.com/mfeckie/imprintor/llms.txt This snippet demonstrates how to generate a PDF with a QR code by importing a Typst package. The NIF automatically downloads and caches the package on the first call. ```elixir template = """ #import "@preview/cades:0.3.1": qr-code = QR Code Demo Scan the code below to visit our website: #qr-code("https://example.com", width: 4cm) *URL:* #sys.inputs.elixir_data.url *Generated:* #sys.inputs.elixir_data.date """ data = %{ "url" => "https://example.com", "date" => "2024-08-15" } config = Imprintor.Config.new(template, data) # On first call the NIF downloads @preview/cades:0.3.1 and caches it. {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) File.write!("qr_demo.pdf", pdf_binary) ``` -------------------------------- ### Compile Typst Template Directly to PDF File Source: https://context7.com/mfeckie/imprintor/llms.txt Use `compile_to_pdf_file/2` to write the compiled PDF directly to disk. This is memory-efficient for large documents. It returns the output path on success or an error reason. ```elixir template = """ = Employee Directory #for emp in sys.inputs.elixir_data.employees [ == #emp.name *Title:* #emp.title *Email:* #emp.email --- ] """ data = %{ "employees" => [ %{"name" => "Alice Johnson", "title" => "Software Engineer", "email" => "alice@co.com"}, %{"name" => "Bob Smith", "title" => "Product Manager", "email" => "bob@co.com"}, %{"name" => "Carol Davis", "title" => "Designer", "email" => "carol@co.com"} ] } config = Imprintor.Config.new(template, data) case Imprintor.compile_to_pdf_file(config, "/tmp/directory.pdf") do {:ok, path} -> IO.puts("Written to #{path}") # => Written to /tmp/directory.pdf {:error, reason} -> IO.inspect(reason, label: "Error") # {:error, "No such file or directory (os error 2)"} for bad paths end ``` -------------------------------- ### Basic PDF Generation with Imprintor Source: https://github.com/mfeckie/imprintor/blob/main/README.md Generate a simple PDF from a Typst template with basic data. Ensure the template and data are correctly defined, then compile and save the PDF. ```elixir # Define a Typst template with data access template = """ = Hello #elixir_data.name! *Date:* #elixir_data.date This is a sample document generated using Imprintor. == Details Here are some details: - *Name:* #sys.inputs.elixir_data.name - *Email:* #sys.inputs.elixir_data.email - *Age:* #sys.inputs.elixir_data.age Thanks for using Imprintor! """ # Provide data to fill the template data = %{ "name" => "John Doe", "date" => "2024-01-15", "email" => "john@example.com", "age" => 30 } # Create a configuration and generate PDF config = Imprintor.Config.new(template, data) {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) # Save to file File.write!("output.pdf", pdf_binary) ``` -------------------------------- ### Imprintor.compile_to_pdf_file/2 Source: https://context7.com/mfeckie/imprintor/llms.txt Compiles a Typst template and writes the PDF directly to disk at the specified output path. This method is efficient for large documents as it avoids holding the entire PDF binary in memory. ```APIDOC ## Imprintor.compile_to_pdf_file/2 ### Description Compiles a Typst template and writes the PDF directly to disk at `output_path`. Returns the path on success, avoiding the need to hold the full binary in memory — useful for large documents. ### Method `Imprintor.compile_to_pdf_file(config, output_path)` ### Parameters #### Path Parameters - `config` (Imprintor.Config.t()) - The configuration object for Imprintor, containing the template and data. - `output_path` (String.t()) - The file path where the compiled PDF will be saved. ### Request Example ```elixir template = "" = Employee Directory #for emp in sys.inputs.elixir_data.employees [ == #emp.name *Title:* #emp.title *Email:* #emp.email --- ] " data = %{ "employees" => [ %{"name" => "Alice Johnson", "title" => "Software Engineer", "email" => "alice@co.com"}, %{"name" => "Bob Smith", "title" => "Product Manager", "email" => "bob@co.com"}, %{"name" => "Carol Davis", "title" => "Designer", "email" => "carol@co.com"} ] } config = Imprintor.Config.new(template, data) case Imprintor.compile_to_pdf_file(config, "/tmp/directory.pdf") do {:ok, path} -> IO.puts("Written to #{path}") # => Written to /tmp/directory.pdf {:error, reason} -> IO.inspect(reason, label: "Error") # {:error, "No such file or directory (os error 2)"} for bad paths end ``` ### Response #### Success Response - `{:ok, output_path}` - Returns the path to the successfully compiled PDF file. #### Error Response - `{:error, reason}` - Returns an error tuple if the compilation fails (e.g., unwritable path, template error). ``` -------------------------------- ### Create Imprintor.Config with all options Source: https://context7.com/mfeckie/imprintor/llms.txt Configure `extra_fonts`, `root_directory`, and `pdf_standard` when creating the `Imprintor.Config`. The `root_directory` is used for resolving file includes and images within the template. ```elixir config = Imprintor.Config.new( "= Custom Font Doc", %{"body" => "Content here"}, extra_fonts: ["assets/fonts/MyFont-Regular.ttf", "assets/fonts"], root_directory: "/projects/my_app", # base for resolving #include / images pdf_standard: "a-3a" # enforce PDF/A-3a ) # => %Imprintor.Config{ # source_document: "= Custom Font Doc", # data: %{"body" => "Content here"}, # extra_fonts: ["assets/fonts/MyFont-Regular.ttf", "assets/fonts"], # root_directory: "/projects/my_app", # pdf_standard: "a-3a" # } ``` -------------------------------- ### Compile template to PDF binary Source: https://context7.com/mfeckie/imprintor/llms.txt Use `Imprintor.compile_to_pdf/1` to compile a Typst template with provided data into an in-memory PDF binary. This is suitable for streaming responses or email attachments. Handles success and error cases. ```elixir template = "\n= Sales Report: #sys.inputs.elixir_data.period\n\n#for region in sys.inputs.elixir_data.regions [\n == #region.name\n\n *Revenue:* $#region.revenue\n *Units Sold:* #region.units\n\n ---\n]\n\n*Grand Total:* $#sys.inputs.elixir_data.grand_total\n" data = %{ "period" => "Q4 2024", "grand_total" => 450_000, "regions" => [ %{"name" => "North", "revenue" => 180_000, "units" => 1_200}, %{"name" => "South", "revenue" => 145_000, "units" => 970}, %{"name" => "West", "revenue" => 125_000, "units" => 850} ] } config = Imprintor.Config.new(template, data) case Imprintor.compile_to_pdf(config) do {:ok, pdf_binary} -> # pdf_binary starts with "%PDF" and can be sent directly File.write!("sales_report.pdf", pdf_binary) IO.puts("PDF size: #{byte_size(pdf_binary)} bytes") # => PDF size: 34821 bytes {:error, reason} -> IO.inspect(reason, label: "Compilation error") end ``` -------------------------------- ### Create Imprintor.Config with data (atom keys) Source: https://context7.com/mfeckie/imprintor/llms.txt Supports atom keys for data maps, which are also accessible via `sys.inputs.elixir_data`. ```elixir config = Imprintor.Config.new( "= #sys.inputs.elixir_data.title", %{title: "Atom Key Report", author: "Dev Team"} ) ``` -------------------------------- ### Imprintor.compile_to_pdf/1 Source: https://context7.com/mfeckie/imprintor/llms.txt Compiles a Typst template and returns the resulting PDF as an in-memory binary. This is suitable for streaming responses or email attachments. ```APIDOC ## Imprintor.compile_to_pdf/1 ### Description Compiles a Typst template and returns the resulting PDF as an in-memory binary. Suitable for streaming responses, email attachments, or any workflow that does not need to write to disk. ### Function Signature `Imprintor.compile_to_pdf(config)` ### Parameters - `config` (%Imprintor.Config{}): The configuration struct created by `Imprintor.Config.new/3`. ### Request Example ```elixir template = """ = Sales Report: #sys.inputs.elixir_data.period #for region in sys.inputs.elixir_data.regions [ == #region.name *Revenue:* $#region.revenue *Units Sold:* #region.units --- ] *Grand Total:* $#sys.inputs.elixir_data.grand_total """ data = %{ "period" => "Q4 2024", "grand_total" => 450_000, "regions" => [ %{"name" => "North", "revenue" => 180_000, "units" => 1_200}, %{"name" => "South", "revenue" => 145_000, "units" => 970}, %{"name" => "West", "revenue" => 125_000, "units" => 850} ] } config = Imprintor.Config.new(template, data) case Imprintor.compile_to_pdf(config) do {:ok, pdf_binary} -> # pdf_binary starts with "%PDF" and can be sent directly File.write!("sales_report.pdf", pdf_binary) IO.puts("PDF size: #{byte_size(pdf_binary)} bytes") # => PDF size: 34821 bytes {:error, reason} -> IO.inspect(reason, label: "Compilation error") end ``` ### Response #### Success Response - `{:ok, binary()}`: The compiled PDF as an in-memory binary. #### Error Response - `{:error, String.t()}`: A string describing the compilation error. ``` -------------------------------- ### Add Imprintor to mix.exs Source: https://context7.com/mfeckie/imprintor/llms.txt Add Imprintor as a dependency in your mix.exs file. Run `mix deps.get` to fetch the precompiled NIF. ```elixir defp deps do [ {:imprintor, "~> 0.6.0"} ] end ``` -------------------------------- ### Imprintor.Config.new/3 Source: https://context7.com/mfeckie/imprintor/llms.txt Builds an Imprintor.Config struct, which bundles the Typst template source, data map, and optional compilation settings. This struct is required for all compile_* functions. ```APIDOC ## Imprintor.Config.new/3 ### Description Creates an `%Imprintor.Config{}` struct that bundles the Typst template source, the data map, and all optional compilation settings. This struct is the required input for every `compile_*` function. ### Function Signature `Imprintor.Config.new(template_source, data \\ %{}, options \\ [])` ### Parameters - `template_source` (String.t()): The Typst template string. - `data` (Map.t()): An Elixir map containing data to be injected into the template. Keys can be strings or atoms. - `options` (Keyword.t()): A keyword list of optional settings. - `:extra_fonts` ([String.t()]): Paths to font files or directories to load in addition to system fonts. - `:root_directory` (String.t()): Base directory for resolving relative file paths inside the template. - `:pdf_standard` (String.t() | nil): PDF standard to enforce (e.g., "a-3a"). ### Request Example ```elixir # Minimal — template only config = Imprintor.Config.new("= Hello World\n\nNo variables here.") # With data (string keys) config = Imprintor.Config.new( "= Invoice #sys.inputs.elixir_data.invoice_number\n\n*Customer:* #sys.inputs.elixir_data.customer\n*Due:* #sys.inputs.elixir_data.due_date", %{ "invoice_number" => "INV-0042", "customer" => "Acme Corp", "due_date" => "2024-09-01" } ) # With data (atom keys — both styles are supported) config = Imprintor.Config.new( "= #sys.inputs.elixir_data.title", %{title: "Atom Key Report", author: "Dev Team"} ) # With all options config = Imprintor.Config.new( "= Custom Font Doc", %{"body" => "Content here"}, extra_fonts: ["assets/fonts/MyFont-Regular.ttf", "assets/fonts"], root_directory: "/projects/my_app", # base for resolving #include / images pdf_standard: "a-3a" # enforce PDF/A-3a ) ``` ### Response Example ```elixir # => %Imprintor.Config{ # source_document: "= Custom Font Doc", # data: %{"body" => "Content here"}, # extra_fonts: ["assets/fonts/MyFont-Regular.ttf", "assets/fonts"], # root_directory: "/projects/my_app", # pdf_standard: "a-3a" # } ``` ``` -------------------------------- ### Specify PDF Standard Option Source: https://github.com/mfeckie/imprintor/blob/main/README.md Generate a PDF while enforcing a specific PDF standard, such as 'a-3a'. This is useful for compliance with document standards. ```elixir template = """ #set document(date: datetime.today()) = Invoice """ config = Imprintor.Config.new(template, %{}, pdf_standard: "a-3a") {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) ``` -------------------------------- ### Enforce PDF Standards with `:pdf_standard` Option Source: https://context7.com/mfeckie/imprintor/llms.txt Specify a PDF standard using the `:pdf_standard` option in `Imprintor.Config.new/3` to ensure the output conforms to specific PDF versions or accessibility requirements. An invalid standard will result in an error. ```elixir # Supported standards: # "1.4", "1.5", "1.6", "1.7", "2.0" # "a-1a", "a-1b", "a-2a", "a-2b", "a-2u" # "a-3a", "a-3b", "a-3u", "a-4", "a-4e", "a-4f" # "ua-1" # Enforce PDF 1.7 config_1_7 = Imprintor.Config.new( "#set document(date: datetime.today())\n= Archived Report", %{}, pdf_standard: "1.7" ) {:ok, _pdf} = Imprintor.compile_to_pdf(config_1_7) # Enforce PDF/UA-1 (accessibility) config_ua = Imprintor.Config.new( "#set document(date: datetime.today())\n= Accessible Doc", %{}, pdf_standard: "ua-1" ) {:ok, _pdf} = Imprintor.compile_to_pdf(config_ua) # Invalid standard → error config_bad = Imprintor.Config.new("= Doc", %{}, pdf_standard: "not-real") {:error, reason} = Imprintor.compile_to_pdf(config_bad) # reason => "Unsupported PDF standard 'not-real'. Supported values: 1.4, 1.5, ..." ``` -------------------------------- ### Tagged Bytes for pdf.attach Source: https://github.com/mfeckie/imprintor/blob/main/README.md Attach binary data, such as XML files, to a PDF using the `pdf.attach` Typst function. Use `Imprintor.bytes/1` to correctly format binary data for Typst. ```elixir template = """ #set document(date: datetime.today()) #pdf.attach( "factur-x.xml", sys.inputs.elixir_data.factur_x_xml, relationship: "alternative", mime-type: "application/xml", description: "Factur-X XML", ) = Invoice """ data = %{ "factur_x_xml" => Imprintor.bytes("...") } config = Imprintor.Config.new(template, data, pdf_standard: "a-3a") {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) ``` -------------------------------- ### Include Custom Fonts with `:extra_fonts` Option Source: https://context7.com/mfeckie/imprintor/llms.txt Make additional fonts available to Typst templates by providing a list of font file or directory paths to the `:extra_fonts` option in `Imprintor.Config.new/3`. This allows for custom branding and typeface usage. ```elixir template = """ #set text(font: "Varela Round", fallback: false) = Custom Branded Report This document uses the *Varela Round* typeface loaded from the project font directory. """ config = Imprintor.Config.new( template, %{}, extra_fonts: ["priv/fonts"] # directory containing VarelaRound-Regular.ttf etc. ) case Imprintor.compile_to_pdf(config) do {:ok, pdf_binary} -> File.write!("branded_report.pdf", pdf_binary) {:error, reason} -> # e.g. "font 'Varela Round' not found" if path is wrong IO.inspect(reason, label: "Font error") end ``` -------------------------------- ### Tag Binary Data as Typst Bytes for PDF Attachments Source: https://context7.com/mfeckie/imprintor/llms.txt Use `Imprintor.bytes/1` to wrap Elixir binaries, enabling them to be recognized as Typst `bytes`. This is necessary for functions like `pdf.attach` when embedding binary data such as XML files into PDFs. ```elixir # Attach an XML file to a PDF/A-3a document (e.g. Factur-X / ZUGFeRD e-invoicing) xml_content = """ INV-2024-001 """ template = """ #set document(date: datetime.today()) #pdf.attach( "factur-x.xml", sys.inputs.elixir_data.xml_data, relationship: "alternative", mime-type: "application/xml", description: "Factur-X structured invoice data", ) = Invoice INV-2024-001 *Vendor:* ACME GmbH *Amount:* €1,234.56 """ data = %{ "xml_data" => Imprintor.bytes(xml_content) # Imprintor.bytes/1 returns {:bytes, xml_content} } config = Imprintor.Config.new(template, data, pdf_standard: "a-3a") {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) File.write!("einvoice.pdf", pdf_binary) ``` -------------------------------- ### Add Imprintor to mix.exs Source: https://github.com/mfeckie/imprintor/blob/main/README.md Add the Imprintor library to your project's dependencies in the mix.exs file. ```elixir def deps do [ {:imprintor, "~> 0.1.0"} ] end ``` -------------------------------- ### PDF Standard Enforcement Source: https://context7.com/mfeckie/imprintor/llms.txt Instructs Typst to validate and output a conformant PDF by specifying a PDF standard using the `:pdf_standard` option in `Imprintor.Config.new/3`. An invalid standard will result in an error tuple without compilation. ```APIDOC ## PDF Standard Enforcement — `:pdf_standard` option ### Description Pass a `:pdf_standard` string in `Imprintor.Config.new/3` options to instruct Typst to validate and output a conformant PDF. An invalid standard returns an error tuple without compiling. ### Method `Imprintor.Config.new(template, data, pdf_standard: "standard_string")` ### Parameters #### Query Parameters - `:pdf_standard` (String.t()) - The desired PDF standard to enforce. Supported standards include: - "1.4", "1.5", "1.6", "1.7", "2.0" - "a-1a", "a-1b", "a-2a", "a-2b", "a-2u" - "a-3a", "a-3b", "a-3u", "a-4", "a-4e", "a-4f" - "ua-1" ### Request Example ```elixir # Supported standards: # "1.4", "1.5", "1.6", "1.7", "2.0" # "a-1a", "a-1b", "a-2a", "a-2b", "a-2u" # "a-3a", "a-3b", "a-3u", "a-4", "a-4e", "a-4f" # "ua-1" # Enforce PDF 1.7 config_1_7 = Imprintor.Config.new( "#set document(date: datetime.today())\n= Archived Report", %{}, pdf_standard: "1.7" ) {:ok, _pdf} = Imprintor.compile_to_pdf(config_1_7) # Enforce PDF/UA-1 (accessibility) config_ua = Imprintor.Config.new( "#set document(date: datetime.today())\n= Accessible Doc", %{}, pdf_standard: "ua-1" ) {:ok, _pdf} = Imprintor.compile_to_pdf(config_ua) # Invalid standard → error config_bad = Imprintor.Config.new("= Doc", %{}, pdf_standard: "not-real") {:error, reason} = Imprintor.compile_to_pdf(config_bad) # reason => "Unsupported PDF standard 'not-real'. Supported values: 1.4, 1.5, ..." ``` ### Response #### Success Response - `{:ok, pdf_binary}` - The compiled PDF binary. #### Error Response - `{:error, reason}` - An error message if the specified PDF standard is invalid or unsupported. ``` -------------------------------- ### Imprintor.bytes/1 Source: https://context7.com/mfeckie/imprintor/llms.txt Tags an Elixir binary as raw Typst bytes, which Imprintor recognizes and converts to a Typst `bytes` value. This is necessary when passing binary data to Typst APIs that expect `bytes`, such as `pdf.attach`. ```APIDOC ## Imprintor.bytes/1 ### Description Tags a binary as raw Typst bytes. Imprintor recognizes this tagged tuple and converts it to a Typst `bytes` value. This is required when passing binary data to Typst APIs that expect `bytes`, such as `pdf.attach`. ### Method `Imprintor.bytes(binary)` ### Parameters #### Path Parameters - `binary` (binary()) - The Elixir binary data to be tagged. ### Request Example ```elixir # Attach an XML file to a PDF/A-3a document (e.g. Factur-X / ZUGFeRD e-invoicing) xm_content = """ INV-2024-001 """ template = "" #set document(date: datetime.today()) #pdf.attach( "factur-x.xml", sys.inputs.elixir_data.xml_data, relationship: "alternative", mime-type: "application/xml", description: "Factur-X structured invoice data", ) = Invoice INV-2024-001 *Vendor:* ACME GmbH *Amount:* €1,234.56 """ data = %{ "xml_data" => Imprintor.bytes(xml_content) # Imprintor.bytes/1 returns {:bytes, xml_content} } config = Imprintor.Config.new(template, data, pdf_standard: "a-3a") {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) File.write!("einvoice.pdf", pdf_binary) ``` ### Response #### Success Response - `{:bytes, binary()}` - A tagged tuple that Imprintor consumes transparently during NIF data conversion. ``` -------------------------------- ### Complex Data and Iteration in PDF Generation Source: https://github.com/mfeckie/imprintor/blob/main/README.md Generate a PDF that iterates over a complex, nested data structure. This is useful for creating directories or lists from dynamic data. ```elixir # Template with data iteration using elixir_data template = """ = Employee Directory #for employee in sys.inputs.elixir_data.employees [ == #employee.name *Position:* #employee.position *Department:* #employee.department *Email:* #employee.email --- ] """ # Complex nested data structure data = %{ "employees" => [ %{ "name" => "Alice Johnson", "position" => "Software Engineer", "department" => "Engineering", "email" => "alice@company.com" }, %{ "name" => "Bob Smith", "position" => "Product Manager", "department" => "Product", "email" => "bob@company.com" } ] } config = Imprintor.Config.new(template, data) {:ok, pdf_binary} = Imprintor.compile_to_pdf(config) File.write!("employee_directory.pdf", pdf_binary) ``` -------------------------------- ### Custom Fonts Source: https://context7.com/mfeckie/imprintor/llms.txt Allows making additional typefaces available inside the Typst template by passing a list of font file paths or directory paths to the `:extra_fonts` option in `Imprintor.Config.new/3`. ```APIDOC ## Custom Fonts — `:extra_fonts` option ### Description Pass a list of font file paths or directory paths to `:extra_fonts` to make additional typefaces available inside the Typst template. ### Method `Imprintor.Config.new(template, data, extra_fonts: [font_path1, font_path2, ...])` ### Parameters #### Query Parameters - `:extra_fonts` (list(String.t())) - A list of file paths or directory paths containing custom font files. ### Request Example ```elixir template = "" #set text(font: "Varela Round", fallback: false) = Custom Branded Report This document uses the *Varela Round* typeface loaded from the project font directory. " config = Imprintor.Config.new( template, %{}, extra_fonts: ["priv/fonts"] # directory containing VarelaRound-Regular.ttf etc. ) case Imprintor.compile_to_pdf(config) do {:ok, pdf_binary} -> File.write!("branded_report.pdf", pdf_binary) {:error, reason} -> # e.g. "font 'Varela Round' not found" if path is wrong IO.inspect(reason, label: "Font error") end ``` ### Response #### Success Response - `{:ok, pdf_binary}` - The compiled PDF binary with custom fonts applied. #### Error Response - `{:error, reason}` - An error message if a specified font is not found or cannot be loaded. ``` -------------------------------- ### Define Imprintor NIF Module Source: https://github.com/mfeckie/imprintor/blob/main/native/imprintor/README.md This Elixir code defines the Imprintor module using Rustler. It specifies the OTP application and crate name, and includes a placeholder function for 'add' that will be overridden by the NIF when loaded. ```elixir defmodule Imprintor do use Rustler, otp_app: :imprintor, crate: "imprintor" # When your NIF is loaded, it will override this function. def add(_a, _b), do: :erlang.nif_error(:nif_not_loaded) end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.