Class Markdown
Draws a Markdown text on as many pages as it needs: headings of # and of underlines, paragraphs with the inline markup of Markup, bullet and numbered lists that nest, block quotes, fenced and indented code, thematic breaks, the tables and the task lists of GitHub's Markdown, - [ ] and
- [x], drawn as boxes, and images alone in their paragraph. In a PDF/UA document the headings are H1 to H6, with no level skipped, the lists are lists, the boxes of the tasks their labels, read as ☐ and ☑, the quotes BlockQuotes, the code Code, the tables tables and the images figures, with their text as the alternate description.
It is not all of Markdown: HTML is drawn as the text it is, a line break is a space, links in a table cell are its text, and an image is drawn only when it is alone in its paragraph, from the directory that SetImageDirectory names; with none, its text is drawn instead, so that a text from anyone reads no file. Please see Example_19.
public class Markdown
- Inheritance
-
Markdown
- Inherited Members
Constructors
Markdown(Font, Font, Font, Font, Font)
Creates the Markdown of text in the fonts, each at its size: the size of the regular font is the size of the text, which the headings are drawn larger than.
public Markdown(Font regular, Font bold, Font italic, Font boldItalic, Font code)
Parameters
regularFontthe font of the text.
boldFontthe font of bold text, and of the headings unless SetHeadingFont sets another.
italicFontthe font of italic text.
boldItalicFontthe font of bold italic text.
codeFontthe font of code, usually a monospaced font.
Methods
DrawOn(PDF, string, List<Page>, PageSize)
Draws the text on as many new pages as it needs. The pages are created detached and added to the list, so that a footer or a page number can be drawn on each before they are added to the PDF. A text with no blocks needs no page.
public float[] DrawOn(PDF pdf, string text, List<Page> pages, PageSize pageSize)
Parameters
pdfPDFthe PDF document.
textstringthe Markdown text.
pagesList<Page>the list that receives the new pages.
pageSizePageSizethe page size, for example Letter.PORTRAIT.
Returns
- float[]
the x and y coordinates of the bottom right corner of the text on the last page.
SetCheckColor(int)
Sets the color of the box of a task that is done, - [x] in the Markdown, as a 0xRRGGBB value, which has a white check mark in it. It is green, 0x1A7F37, unless it is set; Color.transparent leaves it as it is.
public Markdown SetCheckColor(int checkColor)
Parameters
checkColorintthe color.
Returns
- Markdown
this Markdown.
SetHeadingColor(int)
Sets the color of the headings, as a 0xRRGGBB value. They are in the color of the text unless it is set.
public Markdown SetHeadingColor(int headingColor)
Parameters
headingColorintthe color.
Returns
- Markdown
this Markdown.
SetHeadingFont(Font)
Sets the font of the headings, which is the bold font unless it is set.
public Markdown SetHeadingFont(Font font)
Parameters
fontFontthe font.
Returns
- Markdown
this Markdown.
SetImageDirectory(string)
Sets the directory that the images are read from: the source of an image in the Markdown is the file of that name in the directory, a JPEG, PNG, BMP or SVG file. A source that is an absolute path, a URL or has .. in it is not read, and neither is any image unless the directory is set: the image's text is drawn instead.
public Markdown SetImageDirectory(string directory)
Parameters
directorystringthe directory.
Returns
- Markdown
this Markdown.
SetLinkColor(int)
Sets the color of the text of links, as a 0xRRGGBB value. They are blue unless it is set.
public Markdown SetLinkColor(int linkColor)
Parameters
linkColorintthe color.
Returns
- Markdown
this Markdown.
SetMargins(float, float, float, float)
Sets the margins of the pages, in points. They are 72 points, an inch, unless they are set.
public Markdown SetMargins(float left, float top, float right, float bottom)
Parameters
leftfloatthe left margin.
topfloatthe top margin.
rightfloatthe right margin.
bottomfloatthe bottom margin.
Returns
- Markdown
this Markdown.