Home Search

DriveWorks Pro 22
PDF: Markdown File to PDF

Send Feedback

PDF: Markdown File to PDF

This Specification Flow Task will create a new PDF document from a Markdown file (.md) styled using a CSS file.

Properties

Property NameDescription
TitleChanges the Title (not the name) of the task.
Markdown FileFile path to the Markdown (.md) file to convert to PDF.

Relative paths are resolved to the Specification directory.

Accepted prefixes: <Project>, <Specification>, <SpecificationMetadata>, <GroupContent>

The Text Document can be used to help create a dynamic, rules based, Specification specific, markdown file.

See Markdown File Syntax below to learn how to construct a Markdown file.

Style Sheet FileFile path to the CSS (.css) file to style the provided Markdown content.

Relative paths are resolved to the Specification directory.

Accepted prefixes: <Project>, <Specification>, <SpecificationMetadata>, <GroupContent>

The style sheet is used to style the data in the markdown file.

This includes defining layout, color and fonts.

This is a required value but can reference an empty .css file, this will result in defaulting to the system settings it is created on.

We do not recommended using an empty .css file as there is less control over the output.

See Style Sheet File Example below for an example of a CSS file.

PDF FileThe file path to save the generated PDF.

Relative paths are resolved to the Specification directory.

Accepted prefixes: <Project>, <Specification>, <SpecificationMetadata>, <GroupContent>

An existing directory is required to save the PDF.

If the path specified does not exist the Task will fail.

To create a folder to save the PDF file consider using the Copy Folder Task, immediately before this task.

If this property evaluates an existing file, it will be overwritten.

Page SizeSpecifies the size for the pages in the generated PDF.

Defaults to A4.

One of: A0, A1, A2, A3, A4, A5, A6, B4, PageLegal, PageLedger, PageLetter.

Is PortraitSpecifies the orientation of the pages in the generated PDF.

True, (the default) means the pages will be in portrait orientation.

False means the pages will be in landscape orientation.

Reference

This Task has been created and tested using Markdown that follows the CommonMark Specification.

This website is also a great resource to learn Markdown.

Example

When this Task is added the properties are static. To be able to build rules on a static property see How To: Change A Static Property To A Dynamic Property.

Property NameExample RuleMeaning
Markdown File "Markdown" & DWSpecification & ".md" The task will use the markdown data inside the Markdown9999.md file located in the Specification folder.
Style Sheet File"DocumentStyle.css"The Markdown data will be styled using DocumentStyle.css stored relative to the Markdown file being driven.
PDF File"C:\DriveWorksData\Specifications\9999\SpecificationData.pdf"The task will save the generated SpecificationData.pdf inside the 9999\SpecificationData folder.
Page SizePageLegalThe generated PDF pages will be Legal US paper size. 215.9 x 355.6 (mm). 8.5 x 14 (inches).
Is PortraitFALSEThe generated PDF pages will be in landscape orientation.

Markdown File Syntax

Headings

MarkdownExampleResult
## My Top Level HeadingMy Top Level Heading
#### My Second Level HeadingMy Second Level Heading
###### My Third Level HeadingMy Third Level Heading

Emphasis

MarkdownExampleResult
*_**Italic*Italic
**_****Bold**Bold
MarkdownExampleResult
[name](url)[DriveWorks](https://www.driveworks.co.uk/)DriveWorks

Lists

MarkdownExampleResult

-

-

-

- Line one

- Line two

- Line three

  • Line one
  • Line two
  • Line three

1.

2.

3.

1. Line one

2. Line two

3. Line three

  1. Line one
  2. Line two
  3. Line three

Images (Local)

Local Images Relative To The Markdown File

The simplest method of including images in the Markdown File is to reference them from the same location as the Markdown file.

The Copy File Task can be used to move or copy any image to this location.

Remove any spaces used in the name of the image.

If this is not possible replace the space with %20 in the Markdown file.

MarkdownExampleResult
![AltText](Image)![DriveWorks Logo](Logo.svg)

Image stored in the same location is the Markdown file.

DriveWorks Logo
![AltText](Image)![DriveWorks Logo](Images/Logo.svg)

Image stored in a sub folder to the Markdown file.

DriveWorks Logo

Local Images Located Away From The Markdown File

Local images are required to have the full file path converted to a universal resource identifier (URI).

To convert a full file path to a URI:

  • Replace the backslash immediately following the drive letter with three forward slashes.

    For example: C:\ will become C:///

  • Replace all other backslashes (denoting child folders) with a single forward slash.

    For example: DriveWorks\Markdown\Images will become DriveWorks/Markdown/Images

  • Replace any spaces (in between any character, including the name of the image) with %20.

    For example: Pdf Images/My Image.png will become Pdf%20Images/My%20Image.png

MarkdownExampleResult
![AltText](URI)![DriveWorks Logo](D:///DriveWorks/PDF%20Images/Logo.svg)DriveWorks Logo

Images (Web)

To reference an image stored on the web use the full URL to the image.

MarkdownExampleResult
![AltText](URL)![DriveWorks Logo](https://www.driveworks.co.uk/Logo.svg)DriveWorks Logo

Tables

HTML tables can be used directly in markdown.

<table>
      <tbody>
            <tr>
                <th>Col1Heading</th>
                <th>Col2Heading</th>
                <th>Col3Heading</th>
            </tr>
            <tr>
                <td>Col1Data</td>
                <td>Col2Data</td>
                <td>Col3Data</td>
            </tr>
      </tbody>
</table>

Style Sheet File Example

The following is an example of a CSS file that can be used to style the Markdown content.

Copy the contents below and paste into a text editor (Notepad).

Save the Notepad file to the location and name specified in the Style Sheet File property, with the extension .css.

/* Markdown Styling -------------------------------------------------*/

@page {
  background-color: #f3f4f6;
}

html {
  background-color: #ffffff;
  padding: 16px;
}

h1 {
  text-align: left;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 24px; 
}

h2 {
  text-align: left;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px; 
}

h3 {
  text-align: left;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px; 
  break-before: always;
}

p {
  text-align: left;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px; 
}

ul {
  list-style-type: square;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px; 
}

ul li {
  text-align: left;
  padding: 6px;
  margin-left: 12px;
}

table {
  table-layout: fixed;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  border-collapse: collapse;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  font-family: Arial, Helvetica, sans-serif;
}


th,
td {
  padding: 8px;
  border: 1px solid #e5e7eb;;
}

th {
  text-align: left;
  font-weight: bold;
  font-size: 12px; 
}

td {
  word-wrap: break-word;
  font-size: 12px; 
}

ol {
  list-style-type: lower-alpha;
  color: #1f2937;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px; 
}

ol li {
  text-align: left;
  padding: 6px;
  margin-left: 12px;
}

img {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 25%;
}

img[alt="localfile"] {
  width: 50%;
}

hr {
  color: #1f2937;
}
code {
  background-color: #374151;
  color: #cecece;
}

Unsupported PDF fonts

The following fonts are unsupported for use in PDF documents:

  • Bahnschrift
  • Berlin Sans FB Demi
  • Cascadia Code
  • Dubai
  • Lucida
  • Magneto
  • Vivaldi
  • Yu Gothic

Using the Task in a Specification Macro

This task has different types of Outputs. For more information about Outputs see Specification Macros Task Node.

Outputs are only available within Specification Macros. Currently Outputs are not available for Specification Flow.

Status Outputs

This task supports Status Outputs. These can be used to perform different actions depending on what the status outcome of the task is. For more information see Status Outputs in the Task Node Outputs section of Specification Macros Task Node.

The status output navigation is as follows:

Success

  • The PDF was successfully created.

Success with Warnings

  • N/A

Failed

  • There was an error.
  • A markdown file could not be found or accessed.
  • The Task failed to create a PDF in the defined location.