Python: Spire.PDF-for-Python

 

# 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()

  

调用:

 

  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 @ 2024-01-11 20:03  ®Geovin Du Dream Park™  阅读(124)  评论(0编辑  收藏  举报