All Projects → Qkyrie → Markdown2pdf

Qkyrie / Markdown2pdf

Licence: lgpl-3.0
A simple library to convert markdown to pdf using Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Markdown2pdf

Crowbook
Converts books written in Markdown to HTML, LaTeX/PDF and EPUB
Stars: ✭ 399 (+873.17%)
Mutual labels:  markdown, pdf
Mkdocs With Pdf
Generate a single PDF file from MkDocs repository.
Stars: ✭ 39 (-4.88%)
Mutual labels:  markdown, pdf
Markdown Resume Js
Turn a simple markdown document into a resume in HTML and PDF
Stars: ✭ 449 (+995.12%)
Mutual labels:  markdown, pdf
Gotenberg Go Client
Go client for the Gotenberg API
Stars: ✭ 35 (-14.63%)
Mutual labels:  markdown, pdf
Recipes
Django application for managing recipes
Stars: ✭ 695 (+1595.12%)
Mutual labels:  markdown, pdf
Letter Boilerplate
Finest letter typesetting from the command line
Stars: ✭ 374 (+812.2%)
Mutual labels:  markdown, pdf
Zettlr
A Markdown Editor for the 21st century.
Stars: ✭ 6,099 (+14775.61%)
Mutual labels:  markdown, pdf
Gotenberg
A Docker-powered stateless API for PDF files.
Stars: ✭ 3,272 (+7880.49%)
Mutual labels:  markdown, pdf
Backslide
💦 CLI tool for making HTML presentations with Remark.js using Markdown
Stars: ✭ 679 (+1556.1%)
Mutual labels:  markdown, pdf
Md2pdf
Offline markdown to pdf, choose -> edit -> transform 🥂
Stars: ✭ 632 (+1441.46%)
Mutual labels:  markdown, pdf
Minder
Mind-mapping application for Elementary OS
Stars: ✭ 306 (+646.34%)
Mutual labels:  markdown, pdf
Markdown2document
turn markdown files to a PDF or HTML document
Stars: ✭ 22 (-46.34%)
Mutual labels:  markdown, pdf
Pandoc Latex Template
A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
Stars: ✭ 3,750 (+9046.34%)
Mutual labels:  markdown, pdf
Md To Pdf
Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
Stars: ✭ 374 (+812.2%)
Mutual labels:  markdown, pdf
Markdown Pdf
Convert markdown to pdf, png or jpeg on the fly in Atom
Stars: ✭ 250 (+509.76%)
Mutual labels:  markdown, pdf
Mdpdf
Markdown to PDF command line app with support for stylesheets
Stars: ✭ 512 (+1148.78%)
Mutual labels:  markdown, pdf
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+5668.29%)
Mutual labels:  markdown, pdf
Pandoc Book Template
A simple Pandoc template to build documents and ebooks.
Stars: ✭ 214 (+421.95%)
Mutual labels:  markdown, pdf
Vscode Markdown Pdf
Markdown converter for Visual Studio Code
Stars: ✭ 571 (+1292.68%)
Mutual labels:  markdown, pdf
Easybook
Book publishing as easy as it should be (built with Symfony components)
Stars: ✭ 744 (+1714.63%)
Mutual labels:  markdown, pdf

Markdown2Pdf

A simple library to convert markdown to pdf, using Java

##Why Sometimes, it might come in handy to create a pdf version of a markdown file. This library combines several other libraries to leverage the hassle of converting everything by yourself.

The codebase is kept fairly small, while still providing a fluent API.

##Prerequisites ###Version 1.0.x This library only relies on the fact that you have at least Java JDK 1.6 installed. We support Java 1.8, and as of version 1.1 (which is still being worked on) we will make great use of the new features Java 8 has to offer.

<dependency>
	<groupId>eu.de-swaef.pdf</groupId>
	<artifactId>Markdown2Pdf</artifactId>
	<version>2.0.1</version>
</dependency>

###Version 1.1.x and up This version of the library will only support Java 1.8.

##Building > git clone https://github.com/Qkyrie/Markdown2Pdf.git > mvn clean install

##API examples Instead of just providing you with examples here, we created an entire Class dedicated on teaching you the basics of the API. The class can be found in the repository, but for the current version, basically, this is it:

/**
 * Welcome to the tutorial for Markdown2Pdf.
 * We tried to create a page to demonstrate how to use our API. But in the end, we found that
 * it was a lot easier to see how to use it when effectively using our code in a working example.
 * <p/>
 * If you look at the examples listed below, you should get the hang of how you'll be able to use
 * and integrate this library in one of your own projects
 */
public class Tutorial {

    @Test
    public void basicExample() throws Markdown2PdfLogicException, ConversionException {

        /*
            Let's create an instance of the markdown2PdfConverter to work with
         */
        Markdown2PdfConverter markdown2PdfConverter =
                Markdown2PdfConverter.newConverter();

        /*
            We'll have to specify where our converter has to get his markdown data.
            With Java 8 in mind, we chose for a more generic approach, where we only have to
            implement a class defined by Markdown2PdfReader
         */
        markdown2PdfConverter.readFrom(() -> "***Test***");

        /*
            Same thing goes for our writer. When the reading, cleaning and converting is done,
            we need to do something with the resulted bytes. What you do with it is entirely up to you.
         */
        markdown2PdfConverter.writeTo(out -> {
            //do something with it here
        });

        /*
            What has the API done at this point? The simple answer: nothing. It only set the states and placeholders
            for what it will be doing. It's lazily executed, which means that you'll have to explicitly make it do the
            work in order for it to read, clean and convert.

            Actually making the API do the work can be done as follows:
         */
        markdown2PdfConverter.doIt();
    }

    /**
     * Our API has been implemented in such a way, that you can use it as a oneliner.
     * The above example can be rewritten, as shown in the this example
     */
    @Test
    public void basicExampleAsOneLiner() throws Markdown2PdfLogicException, ConversionException {
        Markdown2PdfConverter
                .newConverter()
                .readFrom(() -> "***Test***")
                .writeTo(out -> {
                    //here you can just do something with the bytes, like write it to a file
                    //for example.
                })
                .doIt();
    }

    /**
     * It might seem tedious, implementing two interfaces in order to make the execution work, but believe us when
     * we say that it's for the best. With Java 8 in mind, these interfaces will be functional interfaces, and will be
     * replaceable with Lambda expressions.
     *
     * Fortunately, we provided some Simple implementations which can serve as replacement
     * for your own implementation of the interfaces. Just follow the
     */
    @Test
    public void additionalUtilityClasses() {
       utilityReaders();
       utilityWriters();
    }

    /**
     * UtilityReaders are simple implementations of the
     * Markdown2PdfReader interface
     */
    private void utilityReaders() {
        simpleStringMarkdown2PdfReader();
    }

    /**
     * UtilityWriters on the other hand are simple implementation
     * of the Markdown2PdfWriter interface
     */
    private void utilityWriters() {
        simpleFileMarkdown2PdfWriter();
    }

    /**
     * the SimpleStringMarkdown2PdfReader can be used to read from a String. It's the most simple
     * of implementations, which you'll probably find using a lot.
     */
    private void simpleStringMarkdown2PdfReader() {
        Markdown2PdfConverter
                .newConverter()
                .readFrom(new SimpleStringMarkdown2PdfReader("***Test***"));
    }

    /**
     * The SimpleFileMarkdown2PdfWriter implements the Markdown2PdfWriter in such a way, that the only
     * thing you need to provide is a file. It will write the resulted bytes to the file.
     */
    private void simpleFileMarkdown2PdfWriter() {
        Markdown2PdfConverter
                .newConverter()
                .writeTo(new SimpleFileMarkdown2PdfWriter(new File("pathname_comes_here")));
    }

}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].