Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fpdf import FPDF
- from PIL import Image
- pdf = FPDF()
- pdf.add_page()
- pdf.set_xy(0, 0)
- pdf.image('prefeitura1.png', x=65, y=40) #testando
- pdf.image('greyscale.png', x=30, y=85)
- pdf.set_font("Arial", size=15, style = 'B')
- pdf.set_xy(0, 30 + 50)
- tipoVistoria = 'Vistoria 2019.2'
- pdf.cell(ln=1, h=0, align='C', w=0, txt='Autorização de tráfego - ' + tipoVistoria, border=0)
- pdf.set_xy(0, 40 + 50)
- pdf.set_font("Arial", size=12)
- pdf.cell(ln=1, h=0, align='C', w=0, txt='Certificamos que o veículo, citado abaixo, está apto a trafegar e desempenhar suas funções na')
- pdf.set_xy(0, 47 + 50)
- pdf.cell(ln=1, h=0, align='C', w=0, txt='prestação de serviço público de transporte coletivo do município de Maceió.')
- pdf.set_xy(0, 59 + 50)
- pdf.set_font("Arial", size=15, style = 'B')
- pdf.cell(ln=1, h=0, align='C', w=0, txt='EMPRESA ')
- pdf.set_font("Arial", size=12)
- pdf.set_xy(0, 66 + 50) #84
- empresa = 'São Francismo' # companyname
- pdf.cell(ln=1, h=0, align='C' ,w=0, txt= empresa)
- pdf.set_xy(0, 78 + 50)
- pdf.set_font("Arial", size=15, style = 'B')
- pdf.cell(ln=1, h=0, align='C', w=0, txt='PLACA ')
- pdf.set_xy(0, 85 + 50)
- pdf.set_font("Arial", size=12)
- placa = 'KKP1797' # placa
- pdf.cell(ln=1, h=0, align='C', w=0, txt= placa)
- pdf.set_xy(0, 97 + 50)
- pdf.set_font("Arial", size=15, style = 'B')
- pdf.cell(ln=1, h=0, align='C', w=0, txt='N° DE ORDEM ')
- pdf.set_xy(0, 104 + 50)
- pdf.set_font("Arial", size=12)
- nOrdem = '10215' #numero de ordem
- pdf.cell(ln=1, h=0, align='C', w=0, txt= nOrdem)
- pdf.set_xy(0, 116 + 50)
- pdf.set_font("Arial", size=15, style='B')
- pdf.cell(ln=1, h=0, align='C', w=0, txt='CHASSI')
- pdf.set_font("Arial", size=12)
- pdf.set_xy(0, 123 + 50)
- chassi = '9BM3840789B626158' #chassi
- pdf.cell(ln=1, h=0, align='C', w=0, txt= chassi)
- pdf.set_xy(0, 135 + 50)
- pdf.cell(ln=1, h=0, align='C', w=0, txt='Documento de porte obrigatório. A nâo apresentação deste documento sempre que solicitado')
- pdf.set_xy(0, 142 + 50)
- pdf.cell(ln=1, h=0, align='C', w=0, txt='pela fiscalização, implicará na sanção prevista no Anexo I do Regulamento do Serviço Público')
- pdf.set_xy(0, 149 + 50)
- pdf.cell(ln=1, h=0, align='C', w=0, txt='de Transporte Coletivo do Município de Maceió (Decreto n° 7.269 de 11 de Agosto de 2011).')
- pdf.set_xy(0, 161 + 50)
- pdf.set_font("Arial", size=15, style='B')
- validade = '21/23/23' ###validade
- pdf.cell(ln=1, h=0, align='C', w=0, txt='Este documento é válido até: ' + validade)
- pdf.output("auttrafego.pdf")
- ########################## email
- import smtplib
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- from email.mime.base import MIMEBase
- from email import encoders
- import os
- fromaddr = 'vistoria.smtt@gmail.com' #email q envia
- toaddr = 'jslrocha@gmail.com' #email q recebe
- msg = MIMEMultipart()
- msg['From'] = fromaddr
- msg['To'] = toaddr
- msg['Subject'] = "resultado de vistoria - smtt" #assunto
- body = "segue o resultado etc..." #texto do corpo
- msg.attach(MIMEText(body, 'plain'))
- filename = "auttrafego.pdf" #nome do pdf
- # path do documento
- path = os.getcwd() + '\\auttrafego.pdf' #caminho
- print(path)
- attachment = open(path, "rb")
- p = MIMEBase('application', 'octet-stream')
- p.set_payload((attachment).read())
- encoders.encode_base64(p)
- p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
- msg.attach(p)
- s = smtplib.SMTP('smtp.gmail.com', 587)
- s.starttls()
- s.login(fromaddr, "VistoriaSmtt123") #senha
- text = msg.as_string()
- s.sendmail(fromaddr, toaddr, text)
- s.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement