Skip to main content
POST https://api.pdfnoodle.com/v1/tools/convert-markdown-to-pdf

Request

curl --location 'https://api.pdfnoodle.com/v1/tools/convert-markdown-to-pdf' \
--header 'Authorization: Bearer pdfnoodle_api_123456789' \
--header 'Content-Type: application/json' \
--data '{
    "markdown": "# My Report\n\nThis is a **bold** statement.\n\n## Section 1\n\n- Item 1\n- Item 2\n\n```javascript\nconsole.log(\"Hello world\");\n```",
    "pdfOptions": {
        "format": "A4",
        "margin": {
            "top": "20mm",
            "right": "15mm",
            "bottom": "20mm",
            "left": "15mm"
        }
    },
    "finalFilename": "my-report.pdf",
    "expiration": 3600
}'

Response

{
  "status": "SUCCESS",
  "url": "https://s3.amazonaws.com/...",
  "fileName": "my-report.pdf",
  "urlValidUntil": "2025-01-01T02:00:00.000Z"
}
The response contains a url pointing to the generated PDF file on temporary storage. This URL will expire after the time specified in expiration (default: 1 hour).

Supported Markdown Features

The converter supports the full Markdown specification including:
  • Headings (H1 through H6)
  • Text formatting (bold, italic, strikethrough)
  • Lists (ordered and unordered, nested)
  • Tables
  • Code blocks with syntax highlighting (powered by Prism.js)
  • Inline code
  • Links and images
  • Blockquotes
  • Horizontal rules
Code blocks include automatic syntax highlighting for all major programming languages. Just specify the language after the opening triple backticks (e.g., ```javascript).

Custom CSS

You can inject custom CSS to override the default styling:
{
  "markdown": "# Custom Styled Report",
  "customCss": "body { font-family: 'Georgia', serif; } h1 { color: #2563eb; border-bottom: 2px solid #2563eb; }"
}

Parameters

markdown
string
required
The Markdown content to convert to PDF. Cannot be empty.
customCss
string
Custom CSS to apply to the rendered PDF. This will be injected alongside the default styles, allowing you to override any default styling.
pdfOptions
object
Configuration options for the PDF output. See fields below.
pdfOptions.format
string
default:"Letter"
Paper format. One of: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6.
pdfOptions.landscape
boolean
default:"false"
Set to true to use landscape orientation.
pdfOptions.scale
number
default:"1"
Scale of the webpage rendering. Must be between 0.1 and 2.
pdfOptions.printBackground
boolean
default:"false"
Set to true to print background graphics and colors.
pdfOptions.pageRanges
string
Paper ranges to print, e.g., "1-5" or "1,3,5-7". An empty string means all pages are printed.
pdfOptions.margin
object
Page margins. Each value accepts a number (in pixels) or a string with units (px, in, cm, mm).
pdfOptions.margin.top
string | number
Top margin. Default: 0
pdfOptions.margin.right
string | number
Right margin. Default: 0
pdfOptions.margin.bottom
string | number
Bottom margin. Default: 0
pdfOptions.margin.left
string | number
Left margin. Default: 0
finalFilename
string
The desired filename for the generated PDF. Must end with .pdf. If not provided, a random filename will be generated.
expiration
number
default:"3600"
Number of seconds that the generated signed URL will take to expire. Must be between 60 (1 minute) and 604800 (7 days). Default: 3600 (1 hour).