unified

Project: inokawa/remark-pdf

Package: remark-pdf@0.0.9

  1. Dependents: 0
  2. remark plugin to compile markdown to pdf.
  1. remark 205
  2. markdown 151
  3. unist 133
  4. mdast 88

remark-pdf

npm check demo

remark plugin to compile markdown to pdf.

🚧 WIP 🚧

This project is aiming to support all nodes in mdast syntax tree, but currently transformation and stylings may not be well.

If you have some feature requests or improvements, please create a issue or PR.

Demo

https://inokawa.github.io/remark-pdf/

Install

npm install remark-pdf

Usage

Browser

import { unified } from "unified";
import markdown from "remark-parse";
import pdf from "remark-pdf";
import { saveAs } from "file-saver";

const processor = unified().use(markdown).use(pdf, { output: "blob" });

const text = "# hello world";

(async () => {
  const doc = await processor.process(text);
  const blob = await doc.result;
  saveAs(blob, "example.pdf");
})();

Node.js

import { unified } from "unified";
import markdown from "remark-parse";
import pdf from "remark-pdf/node";
import * as fs from "fs";

const processor = unified().use(markdown).use(pdf, { output: "buffer" });

const text = "# hello world";

(async () => {
  const doc = await processor.process(text);
  const buffer = await doc.result;
  fs.writeFileSync("example.pdf", buffer);
})();

Options

KeyDefaultTypeDescription
output"buffer""buffer" "blob"Set output type of VFile.result. buffer is Promise<Buffer>. blob is Promise<Blob>.
infoundefinedTDocumentInformation?
pageMarginsundefinedMargins?
pageOrientationundefinedPageOrientation?
pageSizeundefinedPageSize?
userPasswordundefinedstring?
ownerPasswordundefinedstring?
permissionsundefinedDocumentPermissions?
versionundefinedPDFVersion?
watermarkundefinedWatermark?