Python: Spire.PDF-for-Python

本文介绍了如何在C#中利用Spire.PDFfor.NET库创建一个包含两个列的PDF表格,同时提到了该库支持的PDF功能和安装步骤。
摘要由CSDN通过智能技术生成
# 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值