Skip to main content

PDFmanager

一个简单、强大、中文友好的 PDF 生成库,基于 ReportLab 高级封装。

功能特性

  • 一键生成 PDF
  • 完美支持中文
  • 标题、文本、图片、表格快速生成
  • API 极简易用

快速开始

  1. 克隆项目 git clone https://github.com/jianfei1234/PDFManagers.git

  2. 安装依赖 pip install reportlab

  3. 运行示例 python example.py

使用示例

安装包

pip install PDFManagers

初始化

from PDFManagers import PDFManager
import matplotlib.pyplot as plt
from reportlab.lib.colors import Color

#PDF initialization
pdf = PDFManager('text')
#PDF initialization for chinese
#pdf = PDFManager('text', CNfont = 'path of chinese font.ttc')

插入段落

#insert paragraphs
paragraphs = [[('abc' * 30,)]]
pdf.draw_multiple_styled_paragraphs(paragraphs)

'''
#for paragraphes with defined fontname, font size, font color, paragraph alignment, background, border, textbox width, location
paragraphs = [[('abc' * 30, 'Helvetica', 15, 'red', 1)], [('def' * 30,)]]
paragraphs = [[('abc天' * 30, 'SimHei', 15, 'red', 1)], [('def天' * 30,)]]  #using SimHei for chinese
pdf.draw_multiple_styled_paragraphs(paragraphs,
                                        max_width=400,
                                        border_color='red',
                                        gradient_start=Color(142 / 255, 182 / 255, 6 / 255, 150 / 255),
                                        gradient_end=Color(50 / 255, 109 / 255, 173 / 255, 55 / 255),
                                        gradient_direction='horizontal')
'''

插入图片

#insert picture
pdf._add_picture(r"C:\Users\Administrator\Desktop\制作.png", width = 300, x = None, y = None)

#insert matplotlib plot
plt.plot([0, 1], [0, 1])
pdf._add_picture(plt)

插入表格

#insert table
data = [['ddd', 'fgd\n\nggd', 'ss\ndf', 'dgdf', 'fff'],
        ['ddd', 'fgdggd', 'ssdf', 'dgdf', 'fff'],
        ['ddd', 'fg\ndggd', 'ssdf', 'dgdf', 'fff'],
        ['ddd', 'fgdggd', 'ssdfg\ngfdfgdf', 'dgdf', 'fff'],]
pdf.draw_table(data, caption='title', note='note')

保存

#save pdf
pdf.save()

版权说明

Copyright © 2026 【Ma Jianfei】 本库仅限个人学习使用,商业用途请购买授权。

Release files for PDFManagers 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PDFManagers 1.0.4
File Size Uploaded
pdfmanagers-1.0.4.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PDFManagers 1.0.4
File Interpreter ABI Platform
pdfmanagers-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 23.6 kB

Release files / pdfmanagers-1.0.4.tar.gz

Download URL pdfmanagers-1.0.4.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6bf8a21a2a3ff06869b7f7ba19228dff596120a7c4d8f7235bb5e1d505b41cb7
BLAKE2b-256 checksum
How to use checksums
31888b123fb03e109a82b663ad352299a9fb59a776716538951f7af1ab4f484b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pdfmanagers-1.0.4-py3-none-any.whl

Download URL pdfmanagers-1.0.4-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4151a0512c7a3a7c8960742afe6929a3aa12cfcbaabf5e7efc2eea9d9949e2c
BLAKE2b-256 checksum
How to use checksums
56558eb20e84dbaa597746d1f0b72c7ea03d43413809519c8734c0ca9f038a48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

1.0.5

2 release files

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page