Skip to content

talerlabs/document-stitcher-cli

Repository files navigation

Document Stitcher

Stitch together Markdown, images, and PDFs into a single printable PDF suitable for submissions, reports, and archives. Write content using familiar Markdown syntax and the tool will render the document, embed external PDFs, inline images when possible, and produce a final PDF ready for distribution.

Author documents in any text editor or generate content with an LLM — the workflow stays the same: write Markdown, reference assets, and let the tool assemble the final PDF.

Markdown Features

Math Expressions

Use LaTeX-style math expressions that will be rendered using MathJax:

Inline math: $E = mc^2$

Display math:
$$\int_{-\infty}^\infty e^{-x^2} dx = \sqrt{\pi}$$

Images

Include images with custom sizes:

![Alt text](path/to/image.jpg =250x150)

Page Breaks

Insert page breaks using:

\pagebreak

PDF Embedding

Embed PDFs that will be included in the final output:

![PDF Document](path/to/document.pdf)

Skipping or Selecting Pages

You can control which pages from an embedded PDF are included using simple operators in the image alt text. Page numbers are 1-indexed.

  • Skip pages: use != followed by a comma-separated list of page numbers to exclude those pages. Example:
![PDF Document !=1,2](path/to/document.pdf)
  • Include pages: use = followed by a comma-separated list of page numbers to include only those pages. Example:
![PDF Document =3,4](path/to/document.pdf)

You cannot specify both != and = for the same PDF (the tool will throw an error).

Theming

Customize the appearance of your generated PDFs by providing a custom CSS file:

document-stitcher input.md output.pdf --theme custom-theme.css

The CSS file will be applied to the HTML before PDF generation, giving you full control over fonts, colors, spacing, and layout. See test_theme.scss for an example of a colorful theme.

Examples

Here are some example PDFs generated from the test fixtures:

License

This project is licensed under the ISC License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Quick CLI for compiling document submissions from markdown, images and other PDFs

Resources

Stars

Watchers

Forks

Packages

No packages published