Skip to content

Markdown2Pdf.Options.SerializableOptions

GitHub Action edited this page Mar 24, 2025 · 2 revisions

Class SerializableOptions

Namespace: Markdown2Pdf.Options
Assembly: Markdown2Pdf.dll

The Markdown2PdfOptions in a serializable format.

public class SerializableOptions

Inheritance

objectSerializableOptions

Inherited Members

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object, object), object.ToString()

Properties

ChromePath

Path to chrome or chromium executable. If set to null downloads chromium by itself. Default: null.

public string? ChromePath { get; set; }

Property Value

string?

CodeHighlightTheme

The theme to use for highlighting code blocks. Default: Github.

public string? CodeHighlightTheme { get; set; }

Property Value

string?

CustomHeadContent

A string containing any content valid inside a HTML <head> to apply extra scripting / styling to the document. Default: null.

public string? CustomHeadContent { get; set; }

Property Value

string?

Examples

Example adding PDF pagebreaks:

options.CustomHeadContent = "h1, h2, h3 { page-break-before: always; }";

DocumentTitle

The title of this document. Can be injected into the header / footer by adding the class document-title to the element. Default: null.

public string? DocumentTitle { get; set; }

Property Value

string?

EnableAutoLanguageDetection

Auto detect the language for code blocks without specfied language. Default: false.

public bool? EnableAutoLanguageDetection { get; set; }

Property Value

bool?

FooterHtml

An HTML string to use as the document-header. Default: null.

public string? FooterHtml { get; set; }

Property Value

string?

Remarks

Html-elements with the classes date, title, document-title, url, pageNumber will get their content replaced based on the information. Note that document-title can be set with the option DocumentTitle.

Format

The paper format for the PDF. Default: A4.

public string? Format { get; set; }

Property Value

string?

HeaderHtml

An HTML string to use as the document-header. Default: null.

public string? HeaderHtml { get; set; }

Property Value

string?

Remarks

Html-elements with the classes date, title, document-title, url, pageNumber will get their content replaced based on the information. Note that document-title can be set with the option DocumentTitle.

IsLandscape

Paper orientation. Default: false.

public bool? IsLandscape { get; set; }

Property Value

bool?

KeepHtml

Doesn't delete the HTML-file used for generating the PDF if set to true. Default: false.

public bool? KeepHtml { get; set; }

Property Value

bool?

MarginOptions

Css-margins for the sides of the document. Default: null.

public MarginOptions? MarginOptions { get; set; }

Property Value

MarginOptions?

MetadataTitle

The title in the metadata (PDF properties). Default: null.

public string? MetadataTitle { get; set; }

Property Value

string?

Remarks

If not set, first DocumentTitle and then the Output-Filename are used as fallback values.

ModuleOptions

Options that decide from where to load additional modules. Default: Remote.

public string? ModuleOptions { get; set; }

Property Value

string?

Scale

Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.

public decimal? Scale { get; set; }

Property Value

decimal?

TableOfContents

Options to create a Table of Contents for the PDF, generated from all headers. The TOC will be inserted into all [TOC], [[TOC]] or <!-- toc --> comments within the markdown document.
Example Markdown document with a TOC:

# My Document
[TOC]
...
Example creating a TOC:
options.TableOfContents = new TableOfContentsOptions {
ListStyle = ListStyle.Decimal,

// Include all heading levels from 2 to 4.
MinDepthLevel = 2,
MaxDepthLevel = 4
};
A header can be omitted from the toc by ending it with <!-- omit from toc -->:
## This header won't be displayed in the TOC &lt;!-- omit from toc --&gt;
public TableOfContentsOptions? TableOfContents { get; set; }

Property Value

TableOfContentsOptions?

Remarks

The TOC gets generated within a <nav class="table-of-contents">. This can be used to apply extra custom styles.

Theme

The styling to apply to the document. Default: Github.

public string? Theme { get; set; }

Property Value

string?

Methods

ToMarkdown2PdfOptions()

Converts this serializable options into proper Markdown2PdfOptions.

public Markdown2PdfOptions ToMarkdown2PdfOptions()

Returns

Markdown2PdfOptions

The deserialized Markdown2PdfOptions.

Clone this wiki locally