Saving your time by automatic convert python code files into pdf files, for KMUTT college students.
LEB2 (Learning Environment version B2) https://www.leb2.org/
git clone https://github.com/monshinawatra/leb2code-pdf.git
cd leb2code-pdf
pip install -r requirements.txt
Inference with leb2code.py
python leb2code.py "ชินวัตร นาไชยธง" # Full name
"65090500408" # KMUTT id
-d "lab5" # Code files directory
-bg "Red (NCS)" # Background color
-o "output/lab5.pdf # Save path
-l # Show line number
Arguments parsing list
-h, --help
show this help message and exit
-d <Dir>, --directory <Dir>
Enter code directory
-k <Keyword>, --keyword <Keyword>
Enter files keyword
-bg <Color>, --background_color <Color>
Enter color name or Hex color code
-t <Theme>, --theme <Theme>
Enter Color theme
-f <Font family>, --font <Font family>
Enter font name (See all names in carbon exported config)
-s <Font size>, --font_size <Font size>
Enter size of font
-l, --line_numbers
Turn on/off line number
-w <Width (px)>, --width <Width (px)>
Width of code snippets
-o <Path>, --save_path <Path>
Enter path for save pdf
Inference in app.py
arguments
Arguments | Default | Type | Description |
---|---|---|---|
name (required) |
str | Your full name. e.g. ชินวัตร นาไชยธง , Shinawatra Nachaithong |
|
id (required) |
str | Your KMUTT college students id. e.g. 65090500000 |
|
dir |
"./" |
str | Your code directory. |
language |
"Python" |
str | Code language. 'python' by default and 'plain-text' for output image |
keyword |
"lab" |
str | All your unique code file name. |
backgroundColor |
"Golden Poppy" |
str | Background color. See all color names, or you can use your custom HEX color code. |
theme |
"Night Owl" |
str | Color theme in code snippet. |
fontFamily |
"Fira Code" |
str | Font family, e.g. JetBrains Mono , Fira Code . See all names in carbon exported config. |
fontSize |
16 |
int | Just size of font in code snippets. |
lineNumbers |
False |
bool | Turn on/off line number |
width |
680 |
int | Width of code snippets |
save_path |
"demo.pdf" |
str | Output path for pdf file. |
paddingVertical |
"50px" |
str | Vertical padding |
paddingHorizontal |
"50px" |
str | Horizontal padding |
Here it is result from carbon "Golden Poppy"
Support themes
Zenburn
Yeti
VSCode
Verminal
Twilight
SynthWave
Solarized (Light)
Solorarized (Dark)
Shades of Purple
Seti
Paraiso
Panda
One Dark
One Light
Oceanic Next
Nord
Night Owl
Monokai
Material
Lucario
Hopscotch
Duotine
Cobalt
Blackboard
Color Name
You can uses these color as name, but if you don't like these colors, you can use your custom hex color code.
- Main application.
- Refactor our code.
- Arguments parsing.
- Beautify code snippets, layout, label in pdf file.
Carbon
Create and share beautiful images of your source code.
https://carbon.now.sh/
Carbon API https://github.com/petersolopov/carbonara
PyFPDF
Free and open-source pure-python PDF library
https://github.com/PyFPDF/fpdf2