Skip to content

C++ API

mkuch edited this page Jul 13, 2026 · 2 revisions

C++ API

The public native exporter API is intentionally small and lives in include/rayomd/tiny_pdf.h.

#include "rayomd/tiny_pdf.h"

#include <string>

std::string pdfBytes;
TinyPdf::PdfOptions options;
options.style = TinyPdf::PdfStyle::Modern;
options.margin = TinyPdf::PdfMargin::Normal();
options.sourcePath = "input.md";
options.enableUrlImages = false;
options.embedSource = false;  // opt in only for exact source recovery

TinyPdf::BuildResult result = TinyPdf::BuildPdf(markdownText, options, pdfBytes);
if (!result) {
    return static_cast<int>(result.error);
}

Set sourcePath for file-based conversions so relative local images resolve next to the input file. By default, image targets must remain inside that source directory after canonicalization. Enable unsafe local paths or URL fetching only for trusted documents.

The header in the source tag you build against is authoritative for that release.

Clone this wiki locally