Python: Spire.PDF-for-Python

发布时间:2024年01月11日
# 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

文章来源:https://blog.csdn.net/geovindu/article/details/135538486
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。