Code block component for PDF documents.
Renders monospaced text with a background box, optional line numbers, and syntax-like styling. Designed for code snippets and terminal output.
Examples
doc |> Pdf.Component.CodeBlock.render({50, 700}, %{width: 400},
"defmodule Hello do\n def world, do: :ok\nend")
doc |> Pdf.Component.CodeBlock.render({50, 700}, %{
width: 400,
line_numbers: true,
background: {0.15, 0.15, 0.18}
color: {0.9, 0.9, 0.9}
}, code)
Summary
Functions
Render a code block at {x, y}.
Functions
Render a code block at {x, y}.
Style options
:width— block width (required):font— monospaced font (default"Courier"):font_size— text size (default9):color— text color (default dark):background— background color (default light gray):border_color— border color (default gray):border_radius— corner radius (default4):padding— inner padding (default10):line_height— spacing between lines (default13):line_numbers— show line numbers (defaultfalse):line_number_color— line number color (default muted):title— optional title/filename above the block