64

GitHub - RelaxedJS/ReLaXed: Create PDF documents using web technologies

 7 years ago
source link: https://github.com/RelaxedJS/ReLaXed
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

logo-blue.png

ReLaXed

ReLaXed is a software to create PDF documents interactively using HTML or Pug (a shorthand for HTML). It enables to define complex layouts with CSS and Javascript while writing the content in a friendly, minimal syntax close to Markdown or LaTeX.

Here it is in action in the Atom editor:

68747470733a2f2f692e696d6775722e636f6d2f344e34665359592e676966

And here are a few output examples:

book_screenshot.png Book - source / PDF letter_screenshot.png Letter - Source / PDF resume_screenshot.png Resume - Source / PDF businesscard_screenshot.png Visit card - Source / PDF slides_screenshot.png Slides - Source / PDF report_screenshot.png Report - Source / PDF paper_screenshot.png Paper - Source / PDF poster_screenshot.png Poster - Source / PDF

ReLaXed has support for Markdown, LaTeX-style mathematical equations (via MathJax), CSV conversion to HTML tables, plots generation (via Vegalite or ChartJS), diagram generation (via Mermaid). Many more features can be added simply by importing an existing Javascript of CSS framework.

Installing ReLaXed

At the moment, the best solution is to install ReLaXed in an empty directory as follows:

git clone https://github.com/RelaxedJS/ReLaXed.git .
npm install
sudo npm link --unsafe-perm=true

This provides your system with the relaxed command.

Hopefully in the future install will be as simple as npm i -g relaxedjs, but there are known issues with puppeteer. In case it doesn't work for you, have a look at the troubleshooting page. Any help towards a simpler install procedure is welcome.

Getting started

To start a project, create a new empty file my_document.pug, and start a ReLaXed process from a terminal:

relaxed my_document.pug

ReLaXed will watch my_document.pug and its directory. Everytime a file changes, my_document.pug will be compiled as my_document.pdf.

Now write and save the following in my_document.pug:

h1 My document's title
p A paragraph in my document

A new file my_document.pdf will be created. Every time you modify and save the sources, the file is automatically updated (make sure to use a PDF viewer with auto-refresh to see you changes happen in real-time). That's all there is to know to start writing your first documents !

To go further:

Why yet another PDF document creator ?

Many of us prefer mark-up languages (Markdown, LaTeX, etc.) to interfaced document editors like Ms Office or Google Docs. This is because mark-up languages make it easier to quickly write documents with consistent style.

However, Markdown is limited to the title/sections/paragraphs structure, and LaTeX has obscure syntax and errors that also make it difficult to go off the beaten tracks.

On the other hand, web technologies have never looked so good.

  • Beautiful CSS frameworks will make sure your documents look clean and modern.
  • There are Javascript libraries for pretty much anything: plotting, highlight code, rendering equations...
  • Millions of people (and growing) know how to use these.
  • Shorthand languages like Pug and SCSS are finally making it fun to write HTML and CSS.
  • (Headless) web browsers can easily turn web documents into PDF, on any platform.

ReLaXed is an attempt at finding the most comfortable way to leverage this for desktop PDF creation.

How ReLaXed works

ReLaXed consists of few lines of code binding together other software. It uses chokidar to watch the file system. when a file is changed, several javascript libraries are used to compile SCSS, Pug, Markdown, and diagram files (mermaid, flowchart, ChartJS) into an HTML page which is then printed to a PDF file by a headless instance of Chromium (via puppeteer).

relaxed_stack.png

Contribute !

ReLaXed is an open source framework originally written by Zulko and released on Github under the ISC licence. Everyone is welcome to contribute!


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK