Files
gotenberg/docs/03-markdown.md
Julien Neuhart 495203c112 v3.0.0 (#18)
2018-12-10 16:09:19 +01:00

1.2 KiB
Raw History

title
title
Markdown

Gotenberg provides the endpoint /convert/markdown for Markdown conversions.

It accepts POST requests with a multipart/form-data Content-Type.

Basic

Markdown conversions work the same as HTML conversions.

Only difference is that you have access to the Go template function toHTML in the file index.html which will convert a given markdown file to HTML.

For instance:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My PDF</title>
  </head>
  <body>
    {{ toHTML .DirPath "file.md" }}
  </body>
</html>

Guzzle

$ curl --request POST \
    --url http://localhost:3000/convert/markdown \
    --header 'Content-Type: multipart/form-data' \
    --form files=@index.html
    --form files=@file.md
    > result.pdf

Go

import "github.com/thecodingmachine/gotenberg/pkg"

func main() {
    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
    req := &gotenberg.MarkdownRequest{
        IndexFilePath: "index.html",
        MarkdownFilePaths: []string{
            "file.md",
        },
    }
    dest := "result.pdf"
    c.Store(req, dest)
}

PHP

TODO