Python: Spire.PDF-for-Python

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# Datetime  : 2024/1/11 10:32
# User      : geovindu
# Product   : PyCharm
# Project   : EssentialAlgorithms
# File      : SimpleTable.py
# explain   : 学习
 
from spire.pdf.common import *
from spire.pdf import *
 
 
class SimpleTable(object):
 
 
    def createtable(self):
        """
        生成表格示例
        :return:
        """
        outputFile = "CreateTwoColumnPDF.pdf"
 
        # Creates a pdf document
        doc = PdfDocument()
        # Creates a new page
        page = doc.Pages.Add()
        s1 = "Spire.PDF for .NET is a professional PDF component applied to creating, writing, " + "editing, handling and reading PDF files without any external dependencies within " + ".NET application. Using this .NET PDF library, you can implement rich capabilities " + "to create PDF files from scratch or process existing PDF documents entirely through " + "C#/VB.NET without installing Adobe Acrobat."
        s2 = "Many rich features can be supported by the .NET PDF API, such as security setting " + "(including digital signature), PDF text/attachment/image extract, PDF merge/split " + ", metadata update, section, graph/image drawing and inserting, table creation and " + "processing, and importing data etc.Besides, Spire.PDF for .NET can be applied to easily " + "converting Text, Image and HTML to PDF with C#/VB.NET in high quality."
        # Get width and height of page
        pageWidth = page.GetClientSize().Width
        pageHeight = page.GetClientSize().Height
        brush = PdfBrushes.get_Black()
        font = PdfFont(PdfFontFamily.TimesRoman, 12.0)
        format = PdfStringFormat(PdfTextAlignment.Justify)
        # Draw text
        page.Canvas.DrawString(s1, font, brush, RectangleF(0.0, 20.0, pageWidth / 2 - 8, pageHeight), format)
        page.Canvas.DrawString(s2, font, brush, RectangleF(pageWidth / 2 + 8, 20.0, pageWidth / 2 - 8, pageHeight),
                               format)
        # Save the document
        doc.SaveToFile(outputFile)
        doc.Close()

  

调用:

 

1
2
simple=BLL.SimpleTable.SimpleTable()
  simple.createtable()

 

python.exe -m pip install --upgrade pip

pip install Spire.Office
pip install Spire.Presentation-for-Python
pip install Spire.Pdf
pip install Spire.Doc
pip install Spire.XLS-for-Python

 

python.exe -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install Spire.Office -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host=https://pypi.tuna.tsinghua.edu.cn
pip install Spire.Presentation-for-Python -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host=https://pypi.tuna.tsinghua.edu.cn
pip install Spire.Pdf -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host=https://pypi.tuna.tsinghua.edu.cn
pip install Spire.Doc -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host=https://pypi.tuna.tsinghua.edu.cn
pip install Spire.XLS-for-Python -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host=https://pypi.tuna.tsinghua.edu.cn

python -m pip install --upgrade pip -i https://pypi.douban.com/simple

 

 


python -m pip install --upgrade pip -i https://pypi.douban.com/simple

pip install josn -i http://pypi.douban.com/simple --trusted-host=pypi.douban.com

清华:https://pypi.tuna.tsinghua.edu.cn/simple
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

 

posted @   ®Geovin Du Dream Park™  阅读(159)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2012-01-11 csharp XmlTextReader read xml file
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示