Skip to main content

Converts given source code into pdf file with syntax highlighting, line numbers and much more

Project description

Code2pdf

Convert various source code into pdf file with syntax highlighting and many more features

Demo

Click above for demo

Dependencies

PyQt

Installation

Build from source

git clone https://github.com/tushar-rishav/code2pdf.git
cd code2pdf
python setup.py install

Or

Using pip

pip install code2pdf

Usage

A. As console app

Help

code2pdf -h

Usage

code2pdf [-h] [-l] [-s SIZE] [-S NAME] [-v] filename [outputfile]

Options

positional arguments:
  filename              absolute path of the python file
  outputfile            absolute path of the output pdf file

optional arguments:
  -h, --help            show this help message and exit
  -l, --linenos         include line numbers.
  -s SIZE, --size SIZE  PDF size. A2,A3,A4,A5 etc
  -S NAME, --style NAME
                        the style name for highlighting. Eg. emacs, vim style etc.
  -v, --version         show program's version number and exit

Available style types are

  • [x] autumn

  • [x] borland

  • [x] bw

  • [x] colorful

  • [x] default

  • [x] emacs

  • [x] friendly

  • [x] fruity

  • [x] igor

  • [x] manni

  • [x] monokai

  • [x] murphy

  • [x] native

  • [x] paraiso-dark

  • [x] paraiso-light

  • [x] pastie

  • [x] perldoc

  • [x] rrt

  • [x] tango

  • [x] trac

  • [x] vim

  • [x] vs

  • [x] xcode

Example

code2pdf -l -s a3 -S emacs ~/Code2Pdf/Code2pdf/code2pdf.py ~/Code2Pdf/Demo/demo.pdf

To see the demo for above check Demo/ in github repo

B. As module

from Code2pdf.code2pdf import Code2pdf
ifile,ofile,size = "test.py", "test.pdf", "A4"
pdf = Code2pdf(ifile, ofile, size)  # create the Py2pdf object
pdf.init_print()    # call print method to print pdf

Contributions

Have an idea to make it better? Go ahead! I will be happy to see a pull request from you! :blush:

Contributor

Christopher Welborn

License

gpl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Code2pdf-0.0.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page