Coder Social home page Coder Social logo

vsimko / figconv Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 0.0 106 KB

Image converter from multiple formats to PDF - useful script for scientific writing e.g. in LaTeX

Home Page: https://github.com/vsimko/figconv

License: MIT License

Shell 79.01% R 1.62% Makefile 19.37%
latex generator images figures vector vector-graphics tex scientific-writing publishing converter

figconv's People

Contributors

vsimko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

figconv's Issues

travis-ci build failed due to missing ghostscript

...
checking dia ... ok
checking odg ... ok
checking ods ... ok
checking odt ... ok
checking R ... ok
checking svg ... ok
checking pdf ... ok
checking png ... ERROR: Ghostscript not installed (gs command)
Selected output format is: pdf
R script loaded
Creating PDF of size 7 x 7 
Now running R code that should plot graphics to the PDF
R code done.
This PDF contains only a single page - splitting not needed
Cropping PDF: ./example1.pdf ... mv: cannot stat ‘.pdfcrop’: No such file or directory
done
...

Add support for Mac

Currently, the tool only runs on Linux.
I hope that it should be possible to support Mac as well (but I don't have a Mac)

Paths should be normalized

Instead of:

Loading /usr/local/bin/../share/figconv-plugins/argparser.sh

The output should be:

Loading /usr/local/share/figconv-plugins/argparser.sh

travis-ci build failed due to missing fakeroot

$ make deb
mkdir -p deb/figconv_4.2/DEBIAN
cp deb-control deb/figconv_4.2/DEBIAN/control
mkdir -p deb/figconv_4.2/usr/
cp -r bin/ deb/figconv_4.2/usr/
cp -r share/ deb/figconv_4.2/usr/
mkdir -p deb/figconv_4.2/usr/share/doc/figconv
cp deb-changelog deb/figconv_4.2/usr/share/doc/figconv/changelog
gzip -n -9 deb/figconv_4.2/usr/share/doc/figconv/changelog
cp LICENSE deb/figconv_4.2/usr/share/doc/figconv/copyright
fakeroot dpkg-deb --build deb/figconv_4.2
make: fakeroot: Command not found
make: *** [deb] Error 127

Add "related work"

Add some section, probably to README.md about other approaches to keep images in sync with the latex code. For example, knitr and sweave.

Programmer's manual

  • describe the architecture of this app (core concepts)
  • how to add plugins
  • how to test the app

bug in system_check function

~/Work/ROADS/smooth-navi-paper/paper/figure_manual $ ls -l
total 1508
-rw-r--r-- 1 vlx vlx  28328 Apr  8 13:23 redirection.odg
-rw-r--r-- 1 vlx vlx 172165 Apr  6 21:36 redirection.png
-rw-r--r-- 1 vlx vlx 411918 Apr  6 21:36 redirection.pptx
-rw-r--r-- 1 vlx vlx 695213 Apr  6 21:36 redirection.xcf
-rw-r--r-- 1 vlx vlx 156315 Apr  6 21:36 roadroid_screenshot.pdf
-rw-r--r-- 1 vlx vlx  26604 Apr  8 12:03 rue_components.odg
-rw-r--r-- 1 vlx vlx  37536 Apr  8 12:03 rue_components.pdf
$ figconv 
Loading /usr/local/bin/../share/figconv-plugins/argparser.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/common-functions.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/dia-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/ooo-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/pdf-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/png-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/R-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/svg-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/system-checks.sh ... ok
All plugins loaded.
--------------------------------------------------------------------------------
find: paths must precede expression: rue_components.odg
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
ERROR: This directory does not contain input images

Add PNG output as an option

The script now generates PDFs, but it should be possible to generate PNGs as well, e.g. in presentations generated in RStudio (*.Rpres files)
These are markdown files that use PNG images, not PDFs

logo / icon needed

Any artists out there who could make a nice vector-based logo + icon ?

How to use R

Describe in more details, how to use R to generate images.
There are some assumptions that need to be considered.

Breaks on filenames with spaces

Given filenames with spaces, generating the PDF works, but cropping the PDF breaks:

checking svg ... ok
checking pdf ... ok
checking png ... ok
Selected output format is: pdf
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This PDF contains only a single page - splitting not needed
Cropping PDF: ./Architektur ... mv: Aufruf von stat für '.pdfcrop' nicht möglich: Datei oder Verzeichnis nicht gefunden
done
Cropping PDF: LoRa.pdf ... mv: Aufruf von stat für '.pdfcrop' nicht möglich: Datei oder Verzeichnis nicht gefunden
done

Make some dependencies optional

Rationale

People won't always use all tools for creating their images. For example, someone might install just Dia and not LibreOffice nor Inkscape.

Error when running `figconv` from Makefile

see stty: /dev/stdin: Inappropriate ioctl for device in:

cd images; figconv
Loading /usr/local/bin/../share/figconv-plugins/argparser.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/common-functions.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/dia-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/ooo-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/pdf-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/png-output.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/R-input.sh ... stty: /dev/stdin: Inappropriate ioctl for device
ok
Loading /usr/local/bin/../share/figconv-plugins/svg-input.sh ... ok
Loading /usr/local/bin/../share/figconv-plugins/system-checks.sh ... ok
All plugins loaded.

move vagrant testing to some other docs

Testing in a virtual machine

Using vagrant + virtualbox

# we need some virtualization backend, here we use virtualbox
sudo apt-get install virtualbox

# install latest vagrant (1.8+ older versions may not work properly)
https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb
dpkg -i vagrant_1.8.1_x86_64.deb

# the VM will live in this directory
mkdir figconv-vm
cd figconv-vm

# now initialize Ubuntu 12.04 LTS (precise)
# same as Travis-CI uses for automated builds
vagrant init hashicorp/precise64
vagrant up
vagrant ssh

Now, you should be logged into the VM running Ubuntu.

# install git and make first
sudo apt-get install git
sudo apt-get install make

# install mandatory dependencies for figconv
sudo apt-get install poppler-utils
sudo apt-get install texlive-extra-utils

# install optional dependencies for figconv
sudo apt-get install dia                  # diagrams made in dia
sudo apt-get install inkscape             # SVG
sudo apt-get install unoconv libreoffice  # Open/LibreOffice formats
sudo apt-get install r-base-core          # when using R

# now install figconv
git clone --depth 1 https://github.com/vsimko/figconv.git
cd figconv
sudo make install

Sample files in tests/ can now be converted.

figconv

# this lists all generated PDF files
ls tests/*.pdf

# copy the generated files from guest vm to host system
cp -r tests /vagrant
exit # now exit the guest vm

ls -l # list the files in your host system

Unoconv fails when libreoffice config is missing

When missing the file ~/.config/libreoffice is missing (e.g just after installing libreoffice), The following error occures:

Error: Unable to connect or start own listener. Aborting.
I/O Error: Couldn't open file './xyz.pdf': No such file or directory.
/usr/local/bin/../share/figconv-plugins/pdf-output.sh: line 46: [: : integer expression expected

The second time it works because ~/.confg/libreoffice has already been created.
This can be fixed by calling: soffice --headless /dev/null

use readthedocs

  • readthedocs can build and host documentation
  • sphinx is a great tool for writing documentation in RST format
  • mkdocs would be even better because it uses Markdown, has a built-in server which refreshes on every change, but it cannot generate PDF and the HTML is not searchable on readthedocs

Typing "y" instead of "yes" failed with return code 2

checking odg ... 10980
ERROR: An instance of LibreOffice or OpenOffice is running.
ERROR: This may cause unoconv tool to fail
Should we kill the process now [yes/no] ? (default=no): y
ERROR: failed with return code 2

unoconv crashes sometimes

When an instance of Open/LibreOffice is running, the unoconv does not generate any PDF.
Closing the Open/LibreOffice window solves the situation, but a reasonable message should be printed to the user as well.

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.