packages = ["fpdf2","pillow","fonttools"] [[fetch]] files = ["./ESCUDO.png"] from js import document from fpdf import FPDF from fpdf.enums import XPos, YPos import base64 import io espacio = ((" "))*25 pdf = FPDF("P", "mm", "letter") pdf.add_page() pdf.set_font("times", "B", 12) pdf.ln(15) pdf.cell(105, 5,text="REPÚBLICA DE CUBA", border=0, align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(105, 5, text="MINISTERIO DE JUSTICIA", border=0, align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(105, 5, text="Registro Central de Sancionados", border=0, align="C") pdf.cell(0, 5, text="SELLO", border=0, align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(105, 5, text="CERTIFICACIÓN DE ANTECEDENTES PENALES", border=0, align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.ln(10) pdf.cell(55, 6, text="Nombre:", border="LTR", align="L") pdf.cell(65, 6, text="Primer apellido:", border="LTR", align="L") pdf.cell(0, 6, text="Segundo apellido:", border="LTR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(55, 6, text=" ", border="LBR", align="L") pdf.cell(65, 6, text=" ", border="LBR", align="L") pdf.cell(0, 6, text=" ", border="LBR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(40, 6, text="Fecha de nacimiento:", border="LTR", align="L") pdf.cell(80, 6, text="Padre:", border="LTR", align="L") pdf.cell(0, 6, text="Madre:", border="LTR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(40, 6, text=" ", border="LBR", align="L") pdf.cell(80, 6, text=" ", border="LBR", align="L") pdf.cell(0, 6, text=" ", border="LBR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(65, 6, text="Lugar de nacimiento:", border="LTR", align="L") pdf.cell(35, 6, text="Ciudadanía:", border="LTR", align="L") pdf.cell(35, 6, text="Identidad:", border="LTR", align="L") pdf.cell(20, 6, text="Sexo:", border="LTR", align="L") pdf.cell(0, 6, text="Piel:", border="LTR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(65, 6, text=" ", border="LBR", align="L") pdf.cell(35, 6, text=" ", border="LBR", align="L") pdf.cell(35, 6, text=" ", border="LBR", align="L") pdf.cell(20, 6, text=" ", border="LBR", align="L") pdf.cell(0, 6, text=" ", border="LBR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.set_font("times", "", 12) pdf.cell(0 , 5, text="El Director del Registro Central de Sancionados, confrontados los archivos de antecedentes penales bajo su ", border="LTR", align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(0 , 5, text=" custodia con las generales de la persona que arriba se consigna CERTIFICA QUE:", border="LR", align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) for i in espacio: pdf.cell(0, 6, i[0], border="LR", align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.set_font("times", "B", 12) pdf.cell(100, 6, text="Válida su presentación durante 1 año después de", border="L", align="C") pdf.cell(45, 6, text=" ", border=0, align="C") pdf.cell(0, 6, text="Director", border="R",align="L", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.cell(0, 2, text="", border="LBR", align="C", new_x=XPos.LMARGIN, new_y=YPos.NEXT) pdf.set_title(title="CERTIFICACIÓN DE ANTECEDENTES PENALES.") pdf.set_author(author="Lázaro Hernández Galbán") pdf.set_creator(creator="Organización Nacional de Bufetes Colectivos") image_url = 'ESCUDO.png' with open(image_url, 'rb') as fp: image_io = io.BytesIO(fp.read()) pdf.image(image_io, 56, 10, 15, 0) # Get the PDF and Base64 encode b64data = base64.b64encode(pdf.output()) # Create an iframe to display the PDF iframe = document.createElement('iframe'); iframe.width = '100%' iframe.height = '1000' iframe.style = 'border: 0' iframe.src = 'data:application/pdf;base64,' + b64data.decode() # Append the iframe to the HTML body document.body.appendChild(iframe);