class Markd::Pdf::Renderer

Defined in:

pdf_renderer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(options : Options = Options.new, style : String = "default", theme : String | Nil = nil, code_theme : String | Nil = nil, page_size : String = "a4", margin_mm : Float64 = 20.0, margins : String | Nil = nil, kdp : Bool = false, mirror_headers : Bool = false, base_dir : String = ".", header : String = "", footer : String = "", html_input : Bool = false, pageless : Bool = false, hyphenate : Bool = false, language : String = "en", css_layers : Array(String) = [] of String) #

[View source]

Instance Method Detail

def add_css(css : String) : Nil #

Layer extra CSS on top of the style (later layers win on equal specificity, like repeated --css flags in the CLI).


[View source]
def base_dir : String #

[View source]
def code_theme : String? #

[View source]
def css : String #

The complete stylesheet this renderer uses: the built-in style, then the theme (when set), then the kdp production layer, then user layers — each later block winning on equal specificity.


[View source]
def css_layers : Array(String) #

[View source]
def footer : String #

[View source]
def header : String #

[View source]
def html_input : Bool #

[View source]
def hyphenate : Bool #

[View source]
def language : String #

[View source]
def margin_mm : Float64 #

[View source]
def options : Markd::Options #

[View source]
def page_size : String #

[View source]
def pageless : Bool #

[View source]
def render(source : String, output_path : String) : Int32 #

Render markdown — or a complete HTML document — to output_path. Returns the page count; raises Markd::Pdf::Error on failure.


[View source]
def render_to_memory(source : String) : Bytes #

Render markdown — or a complete HTML document — to bytes in memory: no PDF file is ever written. Only images that need converting pass through a private temp directory, deleted right after the render. Raises Markd::Pdf::Error on failure.


[View source]
def render_to_memory_with_headings(source : String, toc_html : String | Nil = nil) : Tuple(Bytes, Int32, Array(HeadingEntry)) #

The in-memory twin of render_with_headings: same TOC block and heading map, but the PDF comes back as bytes instead of a file.


[View source]
def render_with_headings(source : String, output_path : String, toc_html : String | Nil = nil) : Tuple(Int32, Array(HeadingEntry)) #

Render with an optional TOC block, as Pdf.toc_html builds it: the block is injected ahead of the body and every heading gets a #mtoc-N anchor the entries can link to. Returns the page count and the heading map the layout produced (index, level, 1-based page, title per heading) — the raw material the two-pass TOC in Markd::Pdf.settled_pages rebuilds the block from. Raises Markd::Pdf::Error on failure.


[View source]
def style : String #

[View source]
def theme : String? #

[View source]