Code Monkey home page Code Monkey logo

drawio2pdf's Introduction

DrawIO2PDF

Intro

Always wondered how to make beautiful mathematical figures with latex inside them? You can use tikz but it's learning curve is steep and many only ascended people can use it fluently. How about draw.io? It allows you to make beautiful figures. What's better, you can latex-type there. But what is that? Have you tried to export it into PDF? No? I don't recommend that if you have a figure full of maths and you still want to have your eyes unharmed.

This is why I created this tool. You can export your figures from draw.io without worrying that it will break any math font. The output is essentially unrecognizable from a standard tikz figure. It will look beautiful in your PDF document and since it's a vector graphic, everyone can zoom in to take a deeper look into your diagram.

Requirements

  • inkscape >= 1.0
  • pdflatex (I use sudo apt-get install texlive-full for that)
  • python >= 3.6

Installation

From the pip repository:

pip install drawio2pdf

or from git:

pip install git+https://github.com/kacperkan/drawio2pdf/

Usage

  1. Create your beautiful diagram, using latex formulas and so on.
  2. Disable Extras > Mathematical Typesetting.
  3. Export your diagram with SVG.
  4. drawio2pdf <path-where-you-saved-your-svg>.

process

The script will a PDF in the same folder and the same file name.

The result:

result

FAQ

Q: I get AssertionError: Incorrect PDF latex generation while running you script!

A: I met these issue personally in one of the following cases:

  • I didn't have pdflatex or inkscape that was runnable from the console
  • I accidentally put a new line in the math formula. When using Mathematical Typesetting, draw.io will render it correctly. However, the SVG file content will be completely broken and it's not that obvious how to parse it with the ETree in python. Solution: Remove any newline in mathematical formulas so they're one liners
  • I totally forgot to turn Mathematical Typesetting off.


Licence

This project is licensed under the terms of the MIT license.

drawio2pdf's People

Contributors

kacperkan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.