Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. from fpdf import FPDF
  2. from PIL import Image
  3.  
  4. pdf = FPDF()
  5. pdf.add_page()
  6. pdf.set_xy(0, 0)
  7. pdf.image('prefeitura1.png', x=65, y=40) #testando
  8. pdf.image('greyscale.png', x=30, y=85)
  9. pdf.set_font("Arial", size=15, style = 'B')
  10. pdf.set_xy(0, 30 + 50)
  11. tipoVistoria = 'Vistoria 2019.2'
  12. pdf.cell(ln=1, h=0, align='C', w=0, txt='Autorização de tráfego - ' + tipoVistoria, border=0)
  13. pdf.set_xy(0, 40 + 50)
  14. pdf.set_font("Arial", size=12)
  15. 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')
  16. pdf.set_xy(0, 47 + 50)
  17. 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ó.')
  18. pdf.set_xy(0, 59 + 50)
  19. pdf.set_font("Arial", size=15, style = 'B')
  20. pdf.cell(ln=1, h=0, align='C', w=0, txt='EMPRESA ')
  21. pdf.set_font("Arial", size=12)
  22. pdf.set_xy(0, 66 + 50) #84
  23. empresa = 'São Francismo' # companyname
  24. pdf.cell(ln=1, h=0, align='C' ,w=0, txt= empresa)
  25. pdf.set_xy(0, 78 + 50)
  26. pdf.set_font("Arial", size=15, style = 'B')
  27. pdf.cell(ln=1, h=0, align='C', w=0, txt='PLACA ')
  28. pdf.set_xy(0, 85 + 50)
  29. pdf.set_font("Arial", size=12)
  30. placa = 'KKP1797' # placa
  31. pdf.cell(ln=1, h=0, align='C', w=0, txt= placa)
  32. pdf.set_xy(0, 97 + 50)
  33. pdf.set_font("Arial", size=15, style = 'B')
  34. pdf.cell(ln=1, h=0, align='C', w=0, txt='N° DE ORDEM ')
  35. pdf.set_xy(0, 104 + 50)
  36. pdf.set_font("Arial", size=12)
  37. nOrdem = '10215' #numero de ordem
  38. pdf.cell(ln=1, h=0, align='C', w=0, txt= nOrdem)
  39. pdf.set_xy(0, 116 + 50)
  40. pdf.set_font("Arial", size=15, style='B')
  41. pdf.cell(ln=1, h=0, align='C', w=0, txt='CHASSI')
  42. pdf.set_font("Arial", size=12)
  43. pdf.set_xy(0, 123 + 50)
  44. chassi = '9BM3840789B626158' #chassi
  45. pdf.cell(ln=1, h=0, align='C', w=0, txt= chassi)
  46. pdf.set_xy(0, 135 + 50)
  47. 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')
  48. pdf.set_xy(0, 142 + 50)
  49. 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')
  50. pdf.set_xy(0, 149 + 50)
  51. 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).')
  52. pdf.set_xy(0, 161 + 50)
  53. pdf.set_font("Arial", size=15, style='B')
  54. validade = '21/23/23' ###validade
  55. pdf.cell(ln=1, h=0, align='C', w=0, txt='Este documento é válido até: ' + validade)
  56.  
  57. pdf.output("auttrafego.pdf")
  58.  
  59. ########################## email
  60.  
  61. import smtplib
  62. from email.mime.multipart import MIMEMultipart
  63. from email.mime.text import MIMEText
  64. from email.mime.base import MIMEBase
  65. from email import encoders
  66. import os
  67.  
  68. fromaddr = 'vistoria.smtt@gmail.com' #email q envia
  69. toaddr = 'jslrocha@gmail.com' #email q recebe
  70.  
  71. msg = MIMEMultipart()
  72. msg['From'] = fromaddr
  73. msg['To'] = toaddr
  74. msg['Subject'] = "resultado de vistoria - smtt" #assunto
  75. body = "segue o resultado etc..." #texto do corpo
  76. msg.attach(MIMEText(body, 'plain'))
  77. filename = "auttrafego.pdf" #nome do pdf
  78. # path do documento
  79. path = os.getcwd() + '\\auttrafego.pdf' #caminho
  80. print(path)
  81. attachment = open(path, "rb")
  82. p = MIMEBase('application', 'octet-stream')
  83. p.set_payload((attachment).read())
  84. encoders.encode_base64(p)
  85. p.add_header('Content-Disposition', "attachment; filename= %s" % filename)
  86. msg.attach(p)
  87. s = smtplib.SMTP('smtp.gmail.com', 587)
  88. s.starttls()
  89. s.login(fromaddr, "VistoriaSmtt123") #senha
  90. text = msg.as_string()
  91. s.sendmail(fromaddr, toaddr, text)
  92. s.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement