python使用fpdf创建pdf文件包含:页眉、页脚并嵌入logo图片、设置使用中文字体
#python使用fpdf创建页眉、页脚并嵌入logo图片、设置使用中文字体
from fpdf import FPDF
class PDF(FPDF):
def header(self):
# Logo
#self.image('logo_pb.png', 10, 8, 33)
self.image('collect.png', 10, 8, 33)
# Arial bold 15
#self.set_font('Arial', 'B', 15)
pdf.add_font('siyuan','',r"C:\Users\liguangdi\AppData\Local\Microsoft\Windows\Fonts\SourceHanSansSC-VF.ttf",True)
pdf.set_font('siyuan', '', 10)
# Move to the right
self.cell(80)
# Title