Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF creation using conda environment. #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pdf/condaCreatePDF.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

#Before launch:
# - install miniconda
# - create environment: $ conda env create --file environment.yml

#Activate conda env
if [ -d "${HOME}/miniconda3" ]; then
source ${HOME}/miniconda3/etc/profile.d/conda.sh
else
CONDA_BASE=$(conda info --base)
source ${CONDA_BASE}/etc/profile.d/conda.sh
fi
conda activate pythonCheatsheet

#Convert MD to html
mdFile=../README.md
grip --title=" " --export ${mdFile}

#Convert html to PDF
# For full help, $ wkhtmltopdf --readme
ouputFile=../Comprehensive-Python-Cheatsheet.pdf
wkhtmltopdf --footer-left '[section] / [subsection]' --footer-line --footer-right '[page]' toc "${mdFile//.md/}.html" "${ouputFile}"
11 changes: 11 additions & 0 deletions pdf/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pythonCheatsheet
channels:
- defaults
- conda-forge
- bioconda
dependencies:
- python=3.6
- wkhtmltopdf
- pip
- pip:
- grip
19 changes: 19 additions & 0 deletions pdf/how_to_create_pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ Printing the PDF
----------------
* Open a PDF that was optimized for printing in Chrome and print on A4 on both sides with default margins, scale 98% and no headers and footers.

How To Create PDF (using conda)
===============================

Note: it was tested on Ubuntu 16.04, this might be compatible with other OS

Setup
-----

* [Install miniconda](https://docs.conda.io/en/latest/miniconda.html) (or anaconda but it's bigger)
* Create environment:
```
$ cd <git-root>/python-cheatsheet/pdf
$ conda env create --file environment.yml
```

Create PDF
----------
* Run shell script:
```
$ ./condaCreatePDF.sh
```
* Voila!