跳转到主要内容

将给定的源代码转换为具有语法高亮、行号等更多功能的PDF文件

项目描述

Code2pdf

将各种源代码转换为具有语法高亮和更多功能的PDF文件

演示

点击上方查看演示

依赖关系

PyQt

安装

从源码构建

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

使用pip

pip install code2pdf

用法

A. 作为控制台应用程序

帮助

code2pdf -h

用法

code2pdf [-h] [-l] [-s SIZE] [-S NAME] [-v] 文件名 [输出文件名]

选项

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

可用的样式类型有

  • [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

示例

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

要查看上述示例,请检查github仓库中的Demo/

B. 作为模块

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

贡献

有改进它的想法?请继续!我将很高兴看到您的pull request!:blush: 在创建PR时,请更新贡献者部分(见下文)。

贡献者

Christopher Welborn

cclauss

许可证

gpl

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

Code2pdf-1.0.0.tar.gz (4.8 kB 查看哈希值)

上传时间

由以下机构支持