Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LA URL:
- path('nacimientos_rp/<int:pk>/',
- login_required(views.r1180_RPnacimientos),
- name='nacimientos_rp'),
- LA VISTA:
- import time
- from io import BytesIO
- from reportlab.pdfgen import canvas
- from django.http import HttpResponse
- from reportlab.lib.enums import TA_JUSTIFY
- from reportlab.lib.pagesizes import letter, legal
- from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image
- from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
- from reportlab.lib.units import cm
- # bases de datos necesarias
- from ..models import Prefec
- import logging
- # configuracion basica de logging:
- logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s - %(levelname)s -%(filename)s:%(lineno)d - %(message)s')
- def r1180_RPnacimientos(request):
- # el response permite enviar el pdf
- response = HttpResponse(content_type='application/pdf')
- # buff permite crear un espacio en la memoria para trabajar el reporte
- buff = BytesIO()
- # configuracion inicial para el documento
- doc = SimpleDocTemplate(buff, pagesize=letter,
- rightMargin=2 * cm, leftMargin=2 * cm,
- topMargin=3 * cm, bottomMargin=2 * cm,
- showBoundary=1)
- # inicializamos el story que es el guion logico para la creacion del pdf
- Story = []
- logo = "./static/base/images/logo_reporte.png"
- magName = "RegistroCivilSantiagoMariño"
- issueNum = 12
- subPrice = "99.00"
- limitedDate = "03/05/2010"
- freeGift = "tin foil hat"
- formatted_time = time.ctime()
- styles = getSampleStyleSheet()
- # se puede modificar los valores del parrafo para que el mimso se adapte a nuestras necesidades
- styles.add(ParagraphStyle(name='Justify',
- alignment=TA_JUSTIFY,
- leading=20,
- fontSize=14))
- Story.append(Spacer(1, 12))
- allprefectura = [(p.pre_mun, p.pre_ciu, p.prefectura, p.tprefec2)
- for p in Prefec.objects.all()]
- ptext3 = '''
- IDENTIDAD Nº E-82.277.499 DE ESTE DOMICILIO, SEGUN CONSTA DE ACTA Nº 548.- ELABORADA EN ESTA FECHA Y POR ANTE
- ESTE DESPACHO Certifica: Que es copia fiel y exacta de su original que se expide a peticion de la parte
- interesada en a los 10 dias del mes de Octubre del 2017.-
- '''
- Story.append(Paragraph(ptext3, styles["Justify"]))
- # Story.append(Paragraph(ptext3, styles["textoPartidas"]))
- Story.append(Spacer(1, 12))
- ptext = 'Abog. <font size=12><b>YENITZA PERDOMO SANCHEZ</b></font>'
- Story.append(Paragraph(ptext, styles["Justify"]))
- # Story.append(Spacer(1, 1))
- ptext = '<b>Directora Del Registro Civil</b>'
- Story.append(Paragraph(ptext, styles["Justify"]))
- doc.build(Story)
- response.write(buff.getvalue())
- return response
Add Comment
Please, Sign In to add comment