def tabla_firmas(self): requerimiento = self.requerimiento p = ParagraphStyle('parrafos', alignment=TA_CENTER, fontSize=8, fontName="Times-Roman") encabezados = [(u'Recepción', '', '', '', '', '')] oficina = requerimiento.oficina jefatura = Puesto.objects.get(oficina=oficina, es_jefatura=True, estado=True) gerencia = Puesto.objects.get(oficina=oficina.gerencia, es_jefatura=True, estado=True) configuracion = Configuracion.objects.first() oficina_administracion = configuracion.administracion presupuesto = configuracion.presupuesto logistica = configuracion.logistica jefatura_administracion = Puesto.objects.get( oficina=oficina_administracion, es_jefatura=True, estado=True) jefatura_presupuesto = Puesto.objects.get(oficina=presupuesto, es_jefatura=True, estado=True) jefatura_logistica = Puesto.objects.get(oficina=logistica, es_jefatura=True, estado=True) jefe = jefatura.trabajador gerente = gerencia.trabajador gerente_administracion = jefatura_administracion.trabajador jefe_logistica = jefatura_logistica.trabajador jefe_presupuesto = jefatura_presupuesto.trabajador archivo_firma_solicitante = os.path.join( settings.MEDIA_ROOT, str(requerimiento.solicitante.firma)) archivo_firma_jefe_departamento = os.path.join(settings.MEDIA_ROOT, str(jefe.firma)) archivo_firma_gerente = os.path.join(settings.MEDIA_ROOT, str(gerente.firma)) archivo_firma_gerente_administracion = os.path.join( settings.MEDIA_ROOT, str(gerente_administracion.firma)) archivo_firma_jefe_oficina_logistica = os.path.join( settings.MEDIA_ROOT, str(jefe_logistica.firma)) archivo_firma_jefe_oficina_presupuesto = os.path.join( settings.MEDIA_ROOT, str(jefe_presupuesto.firma)) firma_solicitante = Image(archivo_firma_solicitante, width=90, height=50, hAlign='CENTER') firma_jefe_departamento = Image(archivo_firma_jefe_departamento, width=90, height=50, hAlign='CENTER') firma_gerente = Image(archivo_firma_gerente, width=90, height=50, hAlign='CENTER') firma_gerente_administracion = Image( archivo_firma_gerente_administracion, width=90, height=50, hAlign='CENTER') firma_jefe_oficina_logistica = Image( archivo_firma_jefe_oficina_logistica, width=90, height=50, hAlign='CENTER') firma_jefe_oficina_presupuesto = Image( archivo_firma_jefe_oficina_presupuesto, width=90, height=50, hAlign='CENTER') if requerimiento.aprobacionrequerimiento.estado == AprobacionRequerimiento.STATUS.PEND: cuerpo = [('', firma_solicitante, '', '', '', '')] solicitante = requerimiento.solicitante.nombre_completo() elif requerimiento.aprobacionrequerimiento.estado == AprobacionRequerimiento.STATUS.APROB_JEF: cuerpo = [('', firma_solicitante, firma_jefe_departamento, '', '', '')] jefe_departamento = jefe elif requerimiento.aprobacionrequerimiento.estado == AprobacionRequerimiento.STATUS.APROB_GER_INM: cuerpo = [('', firma_solicitante, firma_jefe_departamento, firma_gerente, '', '')] elif requerimiento.aprobacionrequerimiento.estado == AprobacionRequerimiento.STATUS.APROB_GER_ADM: cuerpo = [('', firma_solicitante, firma_jefe_departamento, firma_gerente, firma_gerente_administracion, '')] elif requerimiento.aprobacionrequerimiento.estado == AprobacionRequerimiento.STATUS.APROB_LOG: cuerpo = [(firma_jefe_oficina_logistica, firma_solicitante, firma_jefe_departamento, firma_gerente, firma_gerente_administracion, '')] elif requerimiento.aprobacionrequerimiento.estado == AprobacionRequerimiento.STATUS.APROB_PRES: cuerpo = [ (firma_jefe_oficina_logistica, firma_solicitante, firma_jefe_departamento, firma_gerente, firma_gerente_administracion, firma_jefe_oficina_presupuesto) ] try: fecha_recepcion = requerimiento.aprobacionrequerimiento.fecha_recepcion.strftime( '%d/%m/%Y') except: fecha_recepcion = '' pie = [ (Paragraph( 'Fecha: ' + fecha_recepcion + "<br/>" + jefe_logistica.nombre_completo(), p), Paragraph("Solicitado por: <br/>" + solicitante, p), Paragraph('Jefe de Departamento: <br/>' + jefe.nombre_completo(), p), Paragraph( u'V° B° Gerente Inm.: <br/>' + gerente.nombre_completo(), p), Paragraph( u'Vº Bº Gerente Adm.: <br/>' + gerente_administracion.nombre_completo(), p), Paragraph( u'Vº Bº Presupuesto: <br/>' + jefe_presupuesto.nombre_completo(), p)) ] tabla_observaciones = Table(encabezados + cuerpo + pie, colWidths=[ 3.3 * cm, 3.3 * cm, 3.3 * cm, 3.3 * cm, 3.4 * cm, 3.4 * cm ], rowHeights=[0.5 * cm, 2 * cm, 1.8 * cm]) tabla_observaciones.setStyle( TableStyle([ ('GRID', (0, 0), (5, 2), 1, colors.black), ('FONTSIZE', (0, 0), (-1, -1), 8), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('ALIGN', (0, 2), (5, 2), 'CENTER'), ('VALIGN', (0, 0), (-1, -1), 'TOP'), ])) return tabla_observaciones
def ticket(self): monto_ticket = 0 for item in self.lista_ticket: monto_ticket = monto_ticket + item.importe_cobrado obj_E_ticket = E_ticket() obj_E_ticket.monto = monto_ticket obj_E_ticket.fecha = datetime.date.today() obj_E_ticket.nro_credito = self.nro_credito_ticket obj_E_ticket.write_uid = self.singleton_idusu.idusu obj_E_ticket.guardar_ticket(obj_E_ticket) nro_ticket = obj_E_ticket.buscar_ticket(self.nro_credito_ticket) obj_E_party = E_party_party() obj_asoc = obj_E_party.get_party_party(self.obj_form.lne_dni.text()) obj_E_address = E_party_address() obj_address = obj_E_address.get_party_address(obj_asoc.id_party) fec_hoy = datetime.date.today() hoy = fec_hoy.strftime("%d/%m/%Y") styleSheet = getSampleStyleSheet() img = Image("cabezal3.png", 150, 35) img.hAlign = "RIGHT" otro_estilo = ParagraphStyle('', fontSize=6, textColor='#000', leftIndent=0, rightIndent=100) style_barra = ParagraphStyle('', fontSize=10, textColor='#000', leftIndent=0, rightIndent=50) texto_principal = "" texto_secundario = ParagraphStyle('', fontSize=10, textColor='#000', leftIndent=0, rightIndent=0) texto_banner2 = ParagraphStyle('', fontSize=6, textColor='#000', leftIndent=-150, rightIndent=0) estilo_texto = ParagraphStyle( '', fontSize=5, alignment=0, spaceBefore=0, spaceAfter=0, #backColor = '#fff', textColor='#000', leftIndent=5) h = "" #Paragraph("<br/><br/><br/>aa<br/><b>Buenos Aires 53 -Local 2 y 3 -Tel.:02920-432424/ Cel.:02920-15695353</b> ",texto_banner2) banner = [[img, h]] banner2 = [ [ Paragraph('''<font size=3> <b> </b></font>''', styleSheet["BodyText"]) ], [ Paragraph( "<b>Buenos Aires 53 -Local 2 y 3 -Tel.:02920-432424/ Cel.:02920-15695353</b><br/><b> Viedma - Río Negro - E-mail: [email protected]</b> ", texto_banner2) ] ] banner3 = [ [ Paragraph('''<font size=8> <b> </b></font>''', styleSheet["BodyText"]) ], [ Paragraph( "<b>RECIBO N° " + str(nro_ticket) + "<br/>Fecha: " + str(hoy) + "<br/> CUIT: 30-71446302-7 <br/> ING. BRUTOS: 45969604 <br/> INIC. ACTIVIDADES: 20/05/2014</b> ", texto_secundario) ] ] options = QFileDialog.Options() story = [] ban = Table(banner, colWidths=300, rowHeights=70, hAlign="RIGHT") ban2 = Table(banner2, colWidths=300, rowHeights=10) ban3 = Table(banner3, colWidths=318, rowHeights=75, hAlign='RIGHT') tban3 = ban3 tban3.setStyle( TableStyle([('INNERGRID', (0, 1), (-1, -1), 0.25, colors.white), ('BOX', (0, 1), (0, -1), 0.25, colors.white), ('BACKGROUND', (0, 1), (-1, 1), colors.white)])) #story.append(Spacer(100,10)) ##superior d = Drawing(100, 1) d.add(Line(-5, -15, 585, -15)) story.append(d) #izquierda d = Drawing(100, 1) d.add(Line(-5, -15, -5, -94)) story.append(d) story.append(ban) story.append(Spacer(0, 1)) story.append(ban2) story.append(Spacer(0, -150)) story.append(tban3) #centro d = Drawing(100, 1) d.add(Line(250, -2, 250, 79)) story.append(d) #derecha d = Drawing(100, 1) d.add(Line(585, -1, 585, 79)) story.append(d) #inferior d = Drawing(100, 1) d.add(Line(-5, 0, 585, 0)) story.append(d) story.append(Spacer(150, -10)) cabezal = [ [ Paragraph('''<font size=8> <b> </b></font>''', styleSheet["BodyText"]) ], [ Paragraph( '<font size=8> <b> Señor(es): ' + obj_asoc.apellido + ", " + obj_asoc.nombre + '</b> <br/> <b> Domicilio: ' + obj_address.domicilio + '</b><br/></font>', estilo_texto) ] ] tcabezal = Table(cabezal, (590)) tcabezal.setStyle( TableStyle([('INNERGRID', (0, 1), (-1, -1), 0.25, colors.black), ('BOX', (0, 1), (-1, -1), 0.25, colors.black), ('BACKGROUND', (0, 1), (-1, 1), colors.white)])) story.append(tcabezal) story.append(Spacer(0, -15)) integrantes = [ [ Paragraph('''<font size=10> <b> </b></font>''', styleSheet["BodyText"]) ], [ Paragraph('''<font size=10> <b> </b>Credito N°</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Cuota N°</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Monto</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Vencimiento</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Estado</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Descuento</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Interes</font>''', estilo_texto), Paragraph('''<font size=10> <b> </b>Importe</font>''', estilo_texto) ] ] for item in self.lista_ticket: #obj_cuotas.nro_credito = self.nro_credito_historial #obj_cuotas.importe_primer_venc = self.vencimiento_historial.text() #obj_cuotas.primer_Vencimiento = self.vencimiento_historial.text() estilonro_credi = " <font size=8>" + str( item.nro_credito) + "</font>" estilonro_cta = " <font size=8>" + str(item.nro_cuota) + "</font>" estilomonto = " <font size=8>" + str( item.importe_primer_venc) + "</font>" estiloprimer_venc = " <font size=8>" + str( item.primer_Vencimiento) + "</font>" estiloestado_cta = " <font size=8>" + item.estado_cuota + "</font>" estilodescuento = " <font size=8>" + str( item.descuento) + "</font>" estilointeres = " <font size=8>" + str(item.punitorios) + "</font>" estiloimporte = " <font size=8>" + str( item.importe_cobrado) + "</font>" integrantes.append([ Paragraph(estilonro_credi, estilo_texto), Paragraph(estilonro_cta, estilo_texto), Paragraph(estilomonto, estilo_texto), Paragraph(estiloprimer_venc, estilo_texto), Paragraph(estiloestado_cta, estilo_texto), Paragraph(estilodescuento, estilo_texto), Paragraph(estilointeres, estilo_texto), Paragraph(estiloimporte, estilo_texto) ]) tintegrantes = Table(integrantes, (60, 60, 60, 70, 70, 70, 70, 70)) tintegrantes.setStyle( TableStyle([ ('INNERGRID', (0, 1), (-1, -1), 0.25, colors.black), ('BOX', (0, 1), (-1, -1), 0.25, colors.black), ('BACKGROUND', (0, 1), (-1, 1), colors.lightgrey) ])) story.append(tintegrantes) cant_list = len(self.lista_ticket) if (cant_list < 10): result = 11 - cant_list for item in range(1, result): story.append(Spacer(0, 8)) story.append(Spacer(0, 1)) #pyqtRemoveInputHook() #import pdb; pdb.set_trace() a = ("%.2f" % monto_ticket) totales = [[ Paragraph('''<font size=8> <b> </b></font>''', styleSheet["BodyText"]) ], [Paragraph("<b>Importe: $" + str(a) + " </b>", style_barra)]] tota = Table(totales, colWidths=200, rowHeights=20, hAlign='RIGHT') #t=Table(totales, (590)) tota.setStyle( TableStyle([('INNERGRID', (0, 1), (-1, -1), 0.25, colors.black), ('BOX', (0, 1), (-1, -1), 0.25, colors.black), ('BACKGROUND', (0, 1), (-1, 1), colors.white)])) story.append(tota) if cant_list >= 1 and cant_list < 6: story.append(Spacer(0, 50)) elif cant_list > 6 and cant_list < 10: story.append(Spacer(0, 25)) #dejo un mesaje tengo que agregar un while que compara si la cantidad de cuotas pagas es igual # a cantidad el credito esta cancelado #pyqtRemoveInputHook() #import pdb; #pdb.set_trace() if self.credito_cancelado: totales = [[ Paragraph('''<font size=5> <b> </b></font>''', styleSheet["BodyText"]) ], [Paragraph("<b>CREDITO CANCELADO</b>", style_barra)]] tota = Table(totales, colWidths=200, rowHeights=20, hAlign='LEFT') # t=Table(totales, (590)) tota.setStyle( TableStyle([('INNERGRID', (0, 1), (-1, -1), 0.25, colors.black), ('BOX', (0, 1), (-1, -1), 0.25, colors.black), ('BACKGROUND', (0, 1), (-1, 1), colors.white)])) story.append(tota) #-------------Duplicado------------------# ##superior d = Drawing(100, 1) d.add(Line(-5, -15, 585, -15)) story.append(d) #izquierda d = Drawing(100, 1) d.add(Line(-5, -15, -5, -94)) story.append(d) story.append(ban) story.append(Spacer(0, 1)) story.append(ban2) story.append(Spacer(0, -150)) story.append(tban3) #centro d = Drawing(100, 1) d.add(Line(250, -2, 250, 79)) story.append(d) #derecha d = Drawing(100, 1) d.add(Line(585, -1, 585, 79)) story.append(d) #inferior d = Drawing(100, 1) d.add(Line(-5, 0, 585, 0)) story.append(d) story.append(Spacer(150, -10)) story.append(Spacer(0, 10)) story.append(tcabezal) story.append(Spacer(0, 10)) story.append(tintegrantes) cant_list = len(self.lista_ticket) if (cant_list < 10): result = 11 - cant_list for item in range(1, result): story.append(Spacer(0, 8)) story.append(Spacer(0, 1)) story.append(tota) if cant_list >= 1 and cant_list < 6: story.append(Spacer(0, 50)) elif cant_list > 6 and cant_list < 10: story.append(Spacer(0, 25)) #---------------------------------------CAMBIAR RUTA (LA PALABRA slam2016 POR LA RUTA DESEADA DE LA PC)------------------------------------------------# obj_config = configuracion() cadena = obj_config.ruta() file_path = cadena + "/pdf/ticket/ticket" + str( datetime.date.today().year) + "_" + str( datetime.date.today().month) #---EJEMPLO de windows: c:/Users/tatilu-----------------------------------------------------------------------# if not os.path.exists(file_path): os.makedirs(file_path) doc = SimpleDocTemplate(file_path + "/ticket" + obj_asoc.apellido + "_" + obj_asoc.nombre + ".pdf", pagesize=A4, rightMargin=0.5, leftMargin=0.5, topMargin=5, bottomMargin=18) doc.build(story) msgBox = QMessageBox() msgBox.setWindowTitle("Estado de Ticket") msgBox.setText("El ticket se ha generado correctamente : ticket" + obj_asoc.apellido + "_" + obj_asoc.nombre) msgBox.exec_() if sys.platform == 'linux': subprocess.call([ "xdg-open", file_path + "/ticket" + obj_asoc.apellido + "_" + obj_asoc.nombre + ".pdf" ]) else: os.startfile(file_path + "/ticket" + obj_asoc.apellido + "_" + obj_asoc.nombre + ".pdf")
def get_image(self, path, width=1 * cm): """Methode permettant la creation de l'image""" img = ImageReader(path) iw, ih = img.getSize() aspect = ih / float(iw) return Image(path, width=width, height=(width * aspect))
def get_legend(): img = utils.ImageReader("datas/legend.png") iw, ih = img.getSize() ih = ih / iw * 5.9 * inch iw = 5.9 * inch return Image("datas/legend.png", width=iw, height=ih)
def generar_30dias(self): obj_N_cuotas = N_cuotas(1) self.listado_cuotas_30_dias = obj_N_cuotas.lista_cuotas_venc_30_dias() styleSheet = getSampleStyleSheet() #pyqtRemoveInputHook() #import pdb; pdb.set_trace() img = Image("cabezal.png", 250, 75) img.hAlign = "LEFT" #pyqtRemoveInputHook() #import pdb; pdb.set_trace() otro_estilo = ParagraphStyle('', fontSize=20, textColor='#000', leftIndent=200, rightIndent=50) style_barra = ParagraphStyle('', fontSize=13, textColor='#000', backColor='#f5f5f5', borderColor='#a3a3a3', borderWidth=1, borderPadding=(1, 2, 5)) texto_principal = "" estilo_texto = ParagraphStyle( '', fontSize=22, alignment=0, spaceBefore=0, spaceAfter=0, #backColor = '#fff', textColor='#999', leftIndent=10) h = Paragraph(texto_principal, estilo_texto) banner = [[img, h]] options = QFileDialog.Options() story = [] ban = Table(banner, colWidths=300, rowHeights=10) ban.setStyle([('ALIGN', (0, 0), (0, 0), 'LEFT'), ('ALIGN', (0, 0), (1, 0), 'LEFT'), ('VALIGN', (0, 0), (1, 0), 'TOP'), ('TEXTCOLOR', (0, 1), (0, -1), colors.blue)]) story.append(ban) story.append(Spacer(0, -17)) P = Paragraph("<b>Reportes</b> ", otro_estilo) story.append(P) story.append(Spacer(0, 25)) P = Paragraph( "<b>Cuotas vencidas hasta 30 dias</b> " + str(datetime.datetime.now()), style_barra) story.append(P) story.append(Spacer(0, 25)) #nombre apellido dni Nro prestamo nro cuota monto integrantes = [[ Paragraph('''<font size=12> <b> </b></font>''', styleSheet["BodyText"]) ], [ 'Apellido', 'Nombre', 'D.N.I:', 'Nro Crédito:', 'Nro Cuota', 'Monto' ]] #pyqtRemoveInputHook() #import pdb; pdb.set_trace() for item in self.listado_cuotas_30_dias: monto_adeudado = float(item.importe_primer_venc) + float( item.punitorios) obj_N_credito = N_creditos(1) obj_credito = obj_N_credito.buscar_credito_por_nro_credito( item.nro_credito) obj_N_datos_personales_cliente = N_datos_personales_cliente() obj_party = obj_N_datos_personales_cliente.buscar_party_party_por_id( obj_credito.id_party) integrantes.append([ str(obj_party.apellido), str(obj_party.nombre), str(obj_party.nro_doc), str(item.nro_credito), str(item.nro_cuota), str(monto_adeudado) ]) t = Table(integrantes, (150, 135, 100, 55, 55, 55)) t.setStyle( TableStyle([('INNERGRID', (0, 1), (-1, -1), 0.25, colors.black), ('BOX', (0, 1), (-1, -1), 0.25, colors.black), ('BACKGROUND', (0, 1), (-1, 1), colors.lightgrey)])) story.append(t) story.append(Spacer(0, 15)) obj_config = configuracion() cadena = obj_config.ruta() file_path = cadena + "/pdf/listados/list_morosos_30dias" + str( datetime.date.today().year) + "_" + str( datetime.date.today().month) if not os.path.exists(file_path): os.makedirs(file_path) doc = SimpleDocTemplate(file_path + "/listado_de_morosos_30dias.pdf") doc.build(story) msgBox = QMessageBox() msgBox.setWindowTitle("Estado de Listado") msgBox.setText( "El Listado se ha generado correctamente : ticket listado_de_morosos_30dias.pdf" ) msgBox.exec_() if sys.platform == 'linux': subprocess.call( ["xdg-open", file_path + "/listado_de_morosos_30dias.pdf"]) else: os.startfile(file_path + "/listado_de_morosos_30dias.pdf")
def create_sheet(self): styleSheet = getSampleStyleSheet() styNormal = styleSheet['Normal'] styNormal.spaceBefore = 20 styNormal.spaceAfter = 20 styNormal.alignment = 0 # LEFT styleSheet = getSampleStyleSheet() styDescrizione = styleSheet['Normal'] styDescrizione.spaceBefore = 20 styDescrizione.spaceAfter = 20 styDescrizione.alignment = 4 # Justified # format labels # 0 row intestazione = Paragraph( "<b>SCHEDA DI UNITÀ TOPOGRAFICA<br/>" + str(self.datestrfdate()) + "</b>", styNormal) home = os.environ['PYARCHINIT_HOME'] home_DB_path = '{}{}{}'.format(home, os.sep, 'pyarchinit_DB_folder') logo_path = '{}{}{}'.format(home_DB_path, os.sep, 'logo.jpg') logo = Image(logo_path) ## if test_image.drawWidth < 800: logo.drawHeight = 1.5 * inch * logo.drawHeight / logo.drawWidth logo.drawWidth = 1.5 * inch # intestazione2 = Paragraph("<b>pyArchInit</b><br/>www.pyarchinit.blogspot.com", styNormal) # 1 row progetto = Paragraph("<b>Progetto</b><br/>" + str(self.progetto), styNormal) UT = Paragraph("<b>Nr. UT</b><br/>" + str(self.nr_ut), styNormal) UTletterale = Paragraph( "<b>UT letterale<br/>" + str(self.ut_letterale), styNormal) # 2 row descrizione_ut = Paragraph( "<b>Descrizione UT</b><br/>" + self.descrizione_ut, styNormal) interpretazione_ut = Paragraph( "<b>Intepretazione UT</b><br/>" + self.interpretazione_ut, styNormal) # 3 row nazione = Paragraph("<b>Nazione</b><br/>" + self.nazione, styNormal) regione = Paragraph("<b>Regione</b><br/>" + self.regione, styNormal) provincia = Paragraph("<b>Provincia</b><br/>" + self.provincia, styNormal) comune = Paragraph("<b>Comune</b><br/>" + self.comune, styNormal) frazione = Paragraph("<b>Frazione</b><br/>" + self.frazione, styNormal) localita = Paragraph("<b>Localizzazione</b><br/>" + self.localita, styNormal) indirizzo = Paragraph("<b>Indirizzo</b><br/>" + self.indirizzo, styNormal) nr_civico = Paragraph("<b>Nr civico</b><br/>" + self.nr_civico, styNormal) carta_topo_igm = Paragraph("<b>IGM</b><br/>" + self.carta_topo_igm, styNormal) carta_ctr = Paragraph("<b>CTR</b><br/>" + self.carta_ctr, styNormal) coord_geografiche = Paragraph( "<b>Coordinate geografiche</b><br/>" + self.coord_geografiche, styNormal) coord_piane = Paragraph( "<b>Coordinate piane</b><br/>" + self.coord_piane, styNormal) quota = Paragraph("<b>Quota</b><br/>" + self.quota, styNormal) andamento_terreno_pendenza = Paragraph( "<b>Pendenza</b><br/>" + self.andamento_terreno_pendenza, styNormal) utilizzo_suolo_vegetazione = Paragraph( "<b>Utilizzo suolo</b><br/>" + self.utilizzo_suolo_vegetazione, styNormal) descrizione_empirica_suolo = Paragraph( "<b>Descrizione empirica suolo</b><br/>" + self.descrizione_empirica_suolo, styNormal) descrizione_luogo = Paragraph( "<b>Descrizione suolo</b><br/>" + self.descrizione_luogo, styNormal) metodo_rilievo_e_ricognizione = Paragraph( "<b>Tipo ricognizione</b><br/>" + self.metodo_rilievo_e_ricognizione, styNormal) geometria = Paragraph("<b>Geometria</b><br/>" + self.geometria, styNormal) bibliografia = Paragraph( "<b>Bibliografia</b><br/>" + self.bibliografia, styNormal) data = Paragraph("<b>Data</b><br/>" + self.data, styNormal) ora_meteo = Paragraph("<b>Ora e Meteo</b><br/>" + self.ora_meteo, styNormal) responsabile = Paragraph( "<b>Responsabile</b><br/>" + self.responsabile, styNormal) dimensioni_ut = Paragraph( "<b>Dimensioni UT</b><br/>" + self.dimensioni_ut, styNormal) rep_per_mq = Paragraph( "<b>Q.tà per mq </b><br/>" + self.rep_per_mq, styNormal) rep_datanti = Paragraph( "<b>Q.tà datanti</b><br/>" + self.rep_datanti, styNormal) periodo_I = Paragraph("<b>Periodo I</b><br/>" + self.periodo_I, styNormal) datazione_I = Paragraph("<b>Datazione I</b><br/>" + self.frazione, styNormal) interpretazione_I = Paragraph( "<b>Interpretazione I</b><br/>" + self.interpretazione_I, styNormal) periodo_II = Paragraph("<b>Periodo II</b><br/>" + self.periodo_II, styNormal) datazione_II = Paragraph( "<b>Datazione II</b><br/>" + self.datazione_II, styNormal) interpretazione_II = Paragraph( "<b>Interpretazione II</b><br/>" + self.interpretazione_II, styNormal) documentazione = Paragraph( "<b>Documentazione II</b><br/>" + self.documentazione, styNormal) enti_tutela_vincoli = Paragraph( "<b>Ente tutela vincoli</b><br/>" + self.enti_tutela_vincoli, styNormal) indagini_preliminari = Paragraph( "<b>Indagini preliminari</b><br/>" + self.indagini_preliminari, styNormal) # schema cell_schema = [ # 00, 01, 02, 03, 04, 05, 06, 07, 08, 09 rows [ intestazione, '01', '02', '03', '04', '05', '06', logo, '08', '09' ], # 0 row ok [ progetto, '01', '02', '03', '04', UT, '06', '07', UTletterale, '09' ], # 1 row ok [descrizione_ut, '01', '02', '03', '04'], [ interpretazione_ut, '01', '02', '03', '04', '05', '06', '07', '08' ], # 2 row ok [nazione, '01', provincia, '03', regione, '06', comune, '9'], # 3 [ frazione, '01', localita, '03', indirizzo, '05', nr_civico, '08', '09' ], # 4 [ carta_topo_igm, '01', carta_ctr, '03', coord_geografiche, '05', coord_piane, '08', '09' ], # 5 [ quota, '01', andamento_terreno_pendenza, '03', utilizzo_suolo_vegetazione, '05', descrizione_empirica_suolo, '08', '09' ], # 6 [ descrizione_luogo, '01', metodo_rilievo_e_ricognizione, '03', geometria, '05', bibliografia, '08', '09' ], [ data, '01', ora_meteo, '03', responsabile, '05', dimensioni_ut, '08', '09' ], # 7 [ rep_per_mq, '01', rep_datanti, '03', periodo_I, '05', datazione_I, '08', '09' ], # 8 [ interpretazione_I, '01', periodo_II, '03', datazione_II, '05', interpretazione_II, '08', '09' ], # 9 [ documentazione, '01', '02', enti_tutela_vincoli, '03', '04', indagini_preliminari, '09' ] # 10 row ok ] # table style table_style = [ ('GRID', (0, 0), (-1, -1), 0.5, colors.black), # 0 row ('SPAN', (0, 0), (6, 0)), # intestazione ('SPAN', (7, 0), (9, 0)), # intestazione # 1 row ('SPAN', (0, 1), (4, 1)), # dati identificativi ('SPAN', (5, 1), (7, 1)), # dati identificativi ('SPAN', (8, 1), (9, 1)), # dati identificativi # 2 row ('SPAN', (0, 2), (9, 2)), # Definizione - interpretazone ('SPAN', (0, 3), (9, 3)), # definizione - intepretazione # 3 row ('SPAN', (0, 4), (1, 4)), # conservazione - consistenza - colore ('SPAN', (2, 4), (3, 4)), # conservazione - consistenza - colore ('SPAN', (4, 4), (5, 4)), # conservazione - consistenza - colore ('SPAN', (6, 4), (9, 4)), # conservazione - consistenza - colore # 4 row ('SPAN', (0, 5), (1, 5)), # conservazione - consistenza - colore ('SPAN', (2, 5), (3, 5)), # conservazione - consistenza - colore ('SPAN', (4, 5), (5, 5)), # conservazione - consistenza - colore ('SPAN', (6, 5), (9, 5)), # conservazione - consistenza - colore # 5 row ('SPAN', (0, 6), (1, 6)), # conservazione - consistenza - colore ('SPAN', (2, 6), (3, 6)), # conservazione - consistenza - colore ('SPAN', (4, 6), (5, 6)), # conservazione - consistenza - colore ('SPAN', (6, 6), (9, 6)), # conservazione - consistenza - colore # 6 row ('SPAN', (0, 7), (1, 7)), # conservazione - consistenza - colore ('SPAN', (2, 7), (3, 7)), # conservazione - consistenza - colore ('SPAN', (4, 7), (5, 7)), # conservazione - consistenza - colore ('SPAN', (6, 7), (9, 7)), # conservazione - consistenza - colore # 7 row ('SPAN', (0, 8), (1, 8)), # conservazione - consistenza - colore ('SPAN', (2, 8), (3, 8)), # conservazione - consistenza - colore ('SPAN', (4, 8), (5, 8)), # conservazione - consistenza - colore ('SPAN', (6, 8), (9, 8)), # conservazione - consistenza - colore # 8 row ('SPAN', (0, 9), (1, 9)), # conservazione - consistenza - colore ('SPAN', (2, 9), (3, 9)), # conservazione - consistenza - colore ('SPAN', (4, 9), (5, 9)), # conservazione - consistenza - colore ('SPAN', (6, 9), (9, 9)), # conservazione - consistenza - colore # 9 row ('SPAN', (0, 10), (1, 10)), # conservazione - consistenza - colore ('SPAN', (2, 10), (3, 10)), # conservazione - consistenza - colore ('SPAN', (4, 10), (5, 10)), # conservazione - consistenza - colore ('SPAN', (6, 10), (9, 10)), # conservazione - consistenza - colore # 10 row ('SPAN', (0, 11), (1, 11)), # conservazione - consistenza - colore ('SPAN', (2, 11), (3, 11)), # conservazione - consistenza - colore ('SPAN', (4, 11), (5, 11)), ('SPAN', (6, 11), (9, 11)), # conservazione - consistenza - colore ('SPAN', (0, 12), (2, 12)), # conservazione - consistenza - colore ('SPAN', (3, 12), (5, 12)), # conservazione - consistenza - colore ('SPAN', (6, 12), (9, 12)), # conservazione - consistenza - colore ('VALIGN', (0, 0), (-1, -1), 'TOP') ] # 4 row t = Table(cell_schema, colWidths=50, rowHeights=None, style=table_style) return t
import time from reportlab.lib.enums import TA_JUSTIFY from reportlab.lib.pagesizes import letter from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import inch doc = SimpleDocTemplate("06_image.pdf", pagesize=letter, rightMargin=72, leftMargin=0.0 * inch, topMargin=0.0 * inch, bottomMargin=0.0 * inch) width, height = letter print(width, height) Story = [] logo = "margin.png" img_width = 50 img_height = 780 im = Image(filename='margin.png', width=img_width, height=img_height, hAlign='LEFT') Story.append(im) doc.build(Story)
def print_emp_report(request, fid): emp = NonPermanent.objects.select_related().get(parent_id=request.session['matched_employee_id']) reports = NonPermanentUnemploymentMonth.objects.select_related().filter(employee_id=request.session['matched_employee_id'],insurance_file=fid) response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=emp_report.pdf' registerFont(TTFont('DroidSans', os.path.join(settings.MEDIA_ROOT, 'DroidSans.ttf'))) registerFont(TTFont('DroidSans-Bold', os.path.join(settings.MEDIA_ROOT, 'DroidSans-Bold.ttf'))) doc = SimpleDocTemplate(response, pagesize=A4) doc.topMargin = 1.0 * cm doc.leftMargin = 1.5 * cm doc.rightMargin = 1.5 * cm elements = [] head_logo = getSampleStyleSheet() head_logo.add(ParagraphStyle(name='Center', alignment=TA_CENTER, fontName='DroidSans', fontSize=8)) heading_style = getSampleStyleSheet() heading_style.add(ParagraphStyle(name='Center', alignment=TA_CENTER, fontName='DroidSans-Bold', fontSize=12)) heading_style.add(ParagraphStyle(name='Spacer', spaceBefore=5, spaceAfter=5, fontName='DroidSans-Bold', fontSize=12)) signature = getSampleStyleSheet() signature.add(ParagraphStyle(name='Center', alignment=TA_CENTER, fontName='DroidSans', fontSize=10)) tbl_style = getSampleStyleSheet() tbl_style.add(ParagraphStyle(name='Left', alignment=TA_LEFT, fontName='DroidSans', fontSize=10)) tbl_style.add(ParagraphStyle(name='Right', alignment=TA_RIGHT, fontName='DroidSans', fontSize=10)) tbl_style.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, fontName='DroidSans', fontSize=10)) tbl_style.add(ParagraphStyle(name='BoldLeft', alignment=TA_LEFT, fontName='DroidSans-Bold', fontSize=10)) tsl = [('ALIGN', (0, 0), (-1, -1), 'CENTER'), ('FONT', (0, 0), (-1, 0), 'DroidSans'), ('FONTSIZE', (0, 0), (-1, 0), 8), ('BOTTOMPADDING', (0, 0), (-1, -1), 0), ('TOPPADDING', (0, 0), (-1, -1), 0)] tsh = [('ALIGN', (1, 1), (-1, -1), 'LEFT'), ('BOX', (0, 0), (-1, -1), 0.25, colors.black)] ts = [('ALIGN', (1, 1), (-1, -1), 'LEFT'), ('FONT', (0, 0), (-1, 0), 'DroidSans'), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('GRID', (0, 0), (-1, -1), 0.5, colors.black)] tsf = [('ALIGN', (1, 1), (-1, -1), 'CENTER')] for r in reports: data = [] elements.append(Paragraph(u'ΒΕΒΑΙΩΣΗ ΕΡΓΟΔΟΤΗ', heading_style['Center'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) data.append([Paragraph(u'ΕΠΩΝΥΜΙΑ ΕΡΓΟΔΟΤΗ ', tbl_style['Left']) , Paragraph(u'Διεύθυνση ΔΕ %s' % SETTINGS['dide_place'], tbl_style['Left'])]) data.append([Paragraph(u'ΑΡΙΘΜΟΣ ΜΗΤΡΩΟΥ: %s' % SETTINGS['ika_code_dde'], tbl_style['Left']), Paragraph(u'Α.Φ.Μ. ΕΡΓΟΔΟΤΗ: %s' % SETTINGS['afm_dide'], tbl_style['Left'])]) data.append([Paragraph(u'ΑΡΜΟΔΙΟ ΥΠΟΚΑΤΑΣΤΗΜΑ ΙΚΑ ΕΛΕΓΧΟΥ ', tbl_style['Left']), Paragraph(u' ', tbl_style['Left'])]) data.append([Paragraph(u'ΚΩΔΙΚΟΣ - ΟΝΟΜΑΣΙΑ ', tbl_style['Left']), Paragraph(u'%s' % SETTINGS['ika_code'] , tbl_style['Left'])]) table = Table(data, style=tsf, colWidths=[7.0 * cm, 11.0 * cm]) elements.append(table) elements.append(Paragraph(u' ', heading_style['Spacer'])) data = [] elements.append(Paragraph(u'Βεβαιώνουμε ότι:' , tbl_style['Left'])) elements.append(Paragraph(u'Ο/Η ασφαλισμένος με τα κάτωθι ασφαλιστικά στοιχεία απασχολήθηκε στην υπηρεσία μας κατά τις μισθολογικές περιόδους που ακολουθούν:' , tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'ΣΤΟΙΧΕΙΑ ΥΠΑΛΛΗΛΟΥ', tbl_style['BoldLeft'])) data.append([Paragraph(u'ΑΡ. ΠΑΡΑΡΤ. / Κ.Α.Δ. ', tbl_style['Left']), Paragraph(u'%s' % SETTINGS['subject_kad'], tbl_style['Right'])]) data.append([Paragraph(u'ΑΜΑ: ', tbl_style['Left']), Paragraph(u'%s' % emp.ama, tbl_style['Right'])]) data.append([Paragraph(u'Α.Μ.Κ.Α.: ', tbl_style['Left']), Paragraph(u'%s' % emp.social_security_registration_number, tbl_style['Right'])]) data.append([Paragraph(u'ΕΠΩΝΥΜΟ: ', tbl_style['Left']), Paragraph(u'%s' % emp.lastname, tbl_style['Right'])]) data.append([Paragraph(u'ΟΝΟΜΑ: ', tbl_style['Left']), Paragraph(u'%s' % emp.firstname, tbl_style['Right'])]) data.append([Paragraph(u'ΟΝΟΜΑ ΠΑΤΡΟΣ: ', tbl_style['Left']), Paragraph(u'%s' % emp.fathername, tbl_style['Right'])]) data.append([Paragraph(u'ΟΝΟΜΑ ΜΗΤΡΟΣ: ', tbl_style['Left']), Paragraph(u'%s' % emp.mothername, tbl_style['Right'])]) if emp.birth_date == None: data.append([Paragraph(u'ΗΜΕΡΟΜΗΝΙΑ ΓΕΝΝΗΣΕΩΣ: ', tbl_style['Left']), Paragraph(u' ', tbl_style['Right'])]) else: data.append([Paragraph(u'ΗΜΕΡΟΜΗΝΙΑ ΓΕΝΝΗΣΕΩΣ: ', tbl_style['Left']), Paragraph(u'%s / %s / %s' % (emp.birth_date.day, emp.birth_date.month, emp.birth_date.year), tbl_style['Right'])]) data.append([Paragraph(u'Α.Φ.Μ.: ', tbl_style['Left']), Paragraph(u'%s' % emp.vat_number, tbl_style['Right'])]) data.append([Paragraph(u'ΚΩΔΙΚΟΣ ΕΙΔΙΚΟΤΗΤΑΣ: ', tbl_style['Left']), Paragraph(u'%s' % emp.type(), tbl_style['Right'])]) if emp.other_social_security: ec = emp.other_social_security.code else: ec = '101' data.append([Paragraph(u'ΠΑΚΕΤΟ ΚΑΛΥΨΗΣ: ', tbl_style['Left']), Paragraph(u'%s' % ec, tbl_style['Right'])]) data.append([Paragraph(u'ΜΙΣΘΟΛΟΓΙΚΗ ΠΕΡΙΟΔΟΣ: ', tbl_style['Left']), Paragraph(u'%s / %s' % (r.month, r.year), tbl_style['Right'])]) if r.insured_from.strip() in ('', '/ /'): dtf = '01/'+ str(r.month) + '/' + str(r.year) dtt = str(calendar.monthrange(r.year, r.month)[1]) + '/' + str(r.month) + '/' + str(r.year) else: dtf = r.insured_from dtt = r.insured_to data.append([Paragraph(u'ΑΠΟ ΗΜΕΡΟΜΗΝΙΑ ΑΠΑΣΧΟΛΗΣΗΣ: ', tbl_style['Left']), Paragraph(u'%s' % dtf, tbl_style['Right'])]) data.append([Paragraph(u'ΕΩΣ ΗΜΕΡΟΜΗΝΙΑ ΑΠΑΣΧΟΛΗΣΗΣ: ', tbl_style['Left']), Paragraph(u'%s' % dtt, tbl_style['Right'])]) data.append([Paragraph(u'ΤΥΠΟΣ ΑΠΟΔΟΧΩΝ: ', tbl_style['Left']), Paragraph(u'%s' % r.pay_type, tbl_style['Right'])]) data.append([Paragraph(u'ΗΜΕΡΕΣ ΑΣΦΑΛΙΣΗΣ: ', tbl_style['Left']), Paragraph(u'%s' % r.days_insured, tbl_style['Right'])]) lpam = r.total_earned.split('.')[0] rpam = r.total_earned.split('.')[1] if len(rpam) == 1: rpam = rpam + '0' data.append([Paragraph(u'ΑΠΟΔΟΧΕΣ: ', tbl_style['Left']), Paragraph(u'%s.%s' % (lpam, rpam), tbl_style['Right'])]) lpam = r.employee_contributions.split('.')[0] rpam = r.employee_contributions.split('.')[1] if len(rpam) == 1: rpam = rpam + '0' data.append([Paragraph(u'ΕΙΣΦΟΡΕΣ ΑΣΦΑΛΙΣΜΕΝΟΥ: ', tbl_style['Left']), Paragraph(u'%s.%s' % (lpam, rpam), tbl_style['Right'])]) lpam = r.employer_contributions.split('.')[0] rpam = r.employer_contributions.split('.')[1] if len(rpam) == 1: rpam = rpam + '0' data.append([Paragraph(u'ΕΙΣΦΟΡΕΣ ΕΡΓΟΔΟΤΗ: ', tbl_style['Left']), Paragraph(u'%s.%s' % (lpam, rpam), tbl_style['Right'])]) lpam = r.total_contributions.split('.')[0] rpam = r.total_contributions.split('.')[1] if len(rpam) == 1: rpam = rpam + '0' data.append([Paragraph(u'ΣΥΝΟΛΙΚΕΣ ΕΙΣΦΟΡΕΣ: ', tbl_style['Left']), Paragraph(u'%s.%s' % (lpam, rpam), tbl_style['Right'])]) data.append([Paragraph(u'ΚΑΤΑΒΛ. ΕΙΣΦΟΡΕΣ: ', tbl_style['Left']), Paragraph(u'%s.%s' % (lpam, rpam), tbl_style['Right'])]) table = Table(data, style=tsf, colWidths=[10.0 * cm, 8.0 * cm]) elements.append(table) data = [] elements.append(Paragraph(u'Η παραπάνω βεβαίωση χορηγείται για απόδειξη της ασφάλισης στις προαναφερθείσες περιόδους.', tbl_style['Left'])) elements.append(Paragraph(u'ΠΑΡΑΤΗΡΗΣΗ', tbl_style['Left'])) elements.append(Paragraph(u'Τα αναγραφόμενα στην παρούσα Βεβαίωση ασφαλιστικά στοιχεία λαμβάνονται υπόψη μέχρι την επεξεργασία της Α.Π.Δ. των συγκεκριμένων μισθολογικών περιόδων και την υποβολή και έκδοση από το ΙΚΑ του αντίστοιχου Αποσπάσματος Ατομικού Λογαριασμού Ασφάλισης.', tbl_style['Justify'])) today = datetime.date.today() data.append([Paragraph(u' ', signature['Center']) ,Paragraph(u'Ρόδος, %s / %s / %s' % (today.day, today.month, today.year), signature['Center'])]) table = Table(data, style=tsf, colWidths=[9.0 * cm, 8.0 * cm]) elements.append(table) elements.append(Paragraph(u' ', heading_style['Spacer'])) data = [] sign = os.path.join(settings.MEDIA_ROOT, "signature.png") im = Image(sign) im.drawHeight = 3.2 * cm im.drawWidth = 6.5 * cm data.append([Paragraph(u' ', signature['Center']), im]) table = Table(data, style=tsf, colWidths=[10.0 * cm, 7.0 * cm]) elements.append(table) elements.append(PageBreak()) doc.build(elements) return response
def print_exp_report(request): emptype = NonPermanent.objects.select_related().get(parent_id=request.session['matched_employee_id']) response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=exp_report.pdf' registerFont(TTFont('DroidSans', os.path.join(settings.MEDIA_ROOT, 'DroidSans.ttf'))) registerFont(TTFont('DroidSans-Bold', os.path.join(settings.MEDIA_ROOT, 'DroidSans-Bold.ttf'))) doc = SimpleDocTemplate(response, pagesize=A4) doc.topMargin = 1.0 * cm doc.bottomMargin = 1.0 * cm doc.leftMargin = 1.5 * cm doc.rightMargin = 1.5 * cm elements = [] logo = os.path.join(settings.MEDIA_ROOT, "logo.png") width, height = A4 head_logo = getSampleStyleSheet() head_logo.add(ParagraphStyle(name='Center', alignment=TA_CENTER, fontName='DroidSans', fontSize=8)) heading_style = getSampleStyleSheet() heading_style.add(ParagraphStyle(name='Center', alignment=TA_CENTER, fontName='DroidSans-Bold', fontSize=12)) heading_style.add(ParagraphStyle(name='Spacer', spaceBefore=5, spaceAfter=5, fontName='DroidSans-Bold', fontSize=12)) signature = getSampleStyleSheet() signature.add(ParagraphStyle(name='Center', alignment=TA_CENTER, fontName='DroidSans', fontSize=10)) tbl_style = getSampleStyleSheet() tbl_style.add(ParagraphStyle(name='Left', alignment=TA_LEFT, fontName='DroidSans', fontSize=10)) tbl_style.add(ParagraphStyle(name='Right', alignment=TA_RIGHT, fontName='DroidSans', fontSize=10)) tbl_style.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, fontName='DroidSans', fontSize=10)) tbl_style.add(ParagraphStyle(name='BoldLeft', alignment=TA_LEFT, fontName='DroidSans-Bold', fontSize=10)) tbl_style.add(ParagraphStyle(name='BoldRight', alignment=TA_RIGHT, fontName='DroidSans-Bold', fontSize=10)) tsl = [('ALIGN', (0, 0), (-1, -1), 'CENTER'), ('FONT', (0, 0), (-1, 0), 'DroidSans'), ('FONTSIZE', (0, 0), (-1, 0), 8), ('BOTTOMPADDING', (0, 0), (-1, -1), 0), ('TOPPADDING', (0, 0), (-1, -1), 0)] tsh = [('ALIGN', (1, 1), (-1, -1), 'LEFT'), ('BOX', (0, 0), (-1, -1), 0.25, colors.black)] ts = [('ALIGN', (1, 1), (-1, -1), 'LEFT'), ('FONT', (0, 0), (-1, 0), 'DroidSans'), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('GRID', (0, 0), (-1, -1), 0.5, colors.black)] tsf = [('ALIGN', (1, 1), (-1, -1), 'CENTER')] im = Image(logo) im.drawHeight = 1.25 * cm im.drawWidth = 1.25 * cm data = [] date_plus1 = emptype.current_placement().date_to data.append([Paragraph(u'Ρόδος, %s / %s / %s' % (date_plus1.day, date_plus1.month, date_plus1.year), tbl_style['Left'])]) data.append([Paragraph(u' ', heading_style['Spacer'])]) data.append([Paragraph(u' ', heading_style['Spacer'])]) data.append([Paragraph(u'Αρ. Πρωτ.: %s' % protocol_number(emptype.order().order_end_manager), tbl_style['Left'])]) tableh = Table(data, style=tsl, colWidths=[6.0 * cm]) data = [] data.append([im, '', '']) data.append([Paragraph(u'ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ', head_logo['Center']), '', '']) data.append([Paragraph(u'ΥΠΟΥΡΓΕΙΟ ΠΑΙΔΕΙΑΣ', head_logo['Center']), '', '']) data.append([Paragraph(u'ΚΑΙ ΘΡΗΣΚΕΥΜΑΤΩΝ', head_logo['Center']), '', Paragraph(u'Ρόδος, %s / %s / %s' % (date_plus1.day, date_plus1.month, date_plus1.year), tbl_style['Left'])]) data.append([Paragraph(u'ΠΕΡΙΦΕΡΕΙΑΚΗ ΔΙΕΥΘΥΝΣΗ ΠΡΩΤΟΒΑΘΜΙΑΣ', head_logo['Center']), '', Paragraph(u'Αρ. Πρωτ.: %s' % protocol_number(emptype.order().order_end_manager), tbl_style['Left'])]) data.append([Paragraph(u'ΚΑΙ ΔΕΥΤΕΡΟΒΑΘΜΙΑΣ ΕΚΠΑΙΔΕΥΣΗΣ ΝΟΤΙΟΥ ΑΙΓΑΙΟΥ', head_logo['Center']), '', '']) data.append([Paragraph(u'ΔΙΕΥΘΥΝΣΗ ΔΕΥΤΕΡΟΒΑΘΜΙΑΣ ΕΚΠΑΙΔΕΥΣΗΣ ΔΩΔΕΚΑΝΗΣΟΥ', head_logo['Center']), Paragraph(u'ΠΡΟΣ:', tbl_style['BoldRight']), Paragraph(u'%s %s' % (emptype.lastname, emptype.firstname), tbl_style['BoldLeft'])]) table0 = Table(data, style=tsl, colWidths=[8.0 * cm, 5.0 * cm, 6.0 * cm]) elements.append(table0) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Ταχ. Διεύθυνση: %s' % SETTINGS['address'], tbl_style['Left'])) elements.append(Paragraph(u'Πληροφορίες: %s' % SETTINGS['substitutes_contact_person'], tbl_style['Left'])) elements.append(Paragraph(u'Τηλέφωνο: %s' % SETTINGS['substitutes_contact_telephone_number'], tbl_style['Left'])) elements.append(Paragraph(u'Email: %s' % SETTINGS['email_substitutes'], tbl_style['Left'])) elements.append(Paragraph(u'Fax: %s' % SETTINGS['fax_number'], tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'ΘΕΜΑ: Αυτοδίκαιη Απόλυση', tbl_style['BoldLeft'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Σας ανακοινώνουμε ότι με την ταυτάριθμη απόφαση της Διεύθυνσης Δευτεροβάθμιας Εκπαίδευσης %s απολύεστε αυτοδίκαια και χωρίς καμία αποζημίωση από το Δημόσιο από τη θέση του/της προσωρινού/ης αναπληρωτή/τριας καθηγητή/τριας την %s/%s/%s.' % (SETTINGS['dide_place'], emptype.current_placement().date_to.day, emptype.current_placement().date_to.month, emptype.current_placement().date_to.year), tbl_style['Justify'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'ΘΕΜΑ: Βεβαίωση Προϋπηρεσίας', tbl_style['BoldLeft'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) hours_type = '' if emptype.type().id == 1: hours_type = u'(23 ώρες την εβδομάδα)' elements.append(Paragraph(u'Σας ανακοινώνουμε ότι, όπως προκύπτει από το αρχείο που τηρείται στην υπηρεσία μας, ο/η %s %s με όνομα πατρός %s του κλάδου %s %s τοποθετήθηκε στο %s ως %s %s με σχέση εργασίας ιδιωτικού δικαίου ορισμένου χρόνου και υπηρέτησε από %s/%s/%s έως %s/%s/%s.' % (emptype.lastname, emptype.firstname, emptype.fathername, emptype.profession, emptype.profession.description, emptype.current_placement(), emptype.type(), hours_type, emptype.current_placement().date_from.day,emptype.current_placement().date_from.month,emptype.current_placement().date_from.year, emptype.current_placement().date_to.day, emptype.current_placement().date_to.month,emptype.current_placement().date_to.year), tbl_style['Justify'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Απόφαση διορισμού %s: %s %s/%s/%s' % (SETTINGS['ministry_title'], emptype.order().order, emptype.order().date.day, emptype.order().date.month, emptype.order().date.year), tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Απόφαση τοποθέτησης Διευθυντή Δ.Ε. Δωδεκανήσου: %s' % emptype.order().order_start_manager, tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Απόφαση απόλυσης Διευθυντή Δ.Ε. Δωδεκανήσου: %s' % emptype.order().order_end_manager, tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) if emptype.current_placement().substituteplacement.date_from_show: elements.append(Paragraph(u'Ημερομηνία ανάληψης υπηρεσίας: %s/%s/%s' % (emptype.current_placement().substituteplacement.date_from_show.day, emptype.current_placement().substituteplacement.date_from_show.month, emptype.current_placement().substituteplacement.date_from_show.year), tbl_style['Left'])) else: elements.append(Paragraph(u'Ημερομηνία ανάληψης υπηρεσίας: %s/%s/%s' % (emptype.current_placement().date_from.day, emptype.current_placement().date_from.month, emptype.current_placement().date_from.year), tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Χρόνος προϋπηρεσίας για μισθολογικό κλιμάκιο: %s' % emptype.experience_salary(), tbl_style['Left'])) elements.append(Paragraph(u'Χρόνος προϋπηρεσίας για πίνακες αναπληρωτών: %s' % emptype.experience(), tbl_style['Left'])) # if emptype.current_placement().substituteplacement.date_from_show: # elements.append(Paragraph(u'Χρόνος προϋπηρεσίας για μισθολογικό κλιμάκιο: %s/%s/%s - %s/%s/%s' % (emptype.current_placement().substituteplacement.date_from_show.day, emptype.current_placement().substituteplacement.date_from_show.month, emptype.current_placement().substituteplacement.date_from_show.year, emptype.current_placement().date_to.day, emptype.current_placement().date_to.month, emptype.current_placement().date_to.year), tbl_style['Left'])) # else: # elements.append(Paragraph(u'Χρόνος προϋπηρεσίας για μισθολογικό κλιμάκιο: %s/%s/%s - %s/%s/%s' % (emptype.current_placement().date_from.day, emptype.current_placement().date_from.month, emptype.current_placement().date_from.year, emptype.current_placement().date_to.day, emptype.current_placement().date_to.month, emptype.current_placement().date_to.year), tbl_style['Left'])) # elements.append(Paragraph(u'Χρόνος προϋπηρεσίας για πίνακες αναπληρωτών: %s/%s/%s - %s/%s/%s' % (emptype.current_placement().date_from.day, emptype.current_placement().date_from.month, emptype.current_placement().date_from.year, emptype.current_placement().date_to.day, emptype.current_placement().date_to.month, emptype.current_placement().date_to.year), tbl_style['Left'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Το πλήρες ωράριο εβδομαδιαίας διδακτικής απασχόλησης των εκπαιδευτικών της Δευτεροβάθμιας Εκπαίδευσης κλάδων ΠΕ που ισχύει σύμφωνα με τον Ν.4152/2013 είναι 23 ώρες.', tbl_style['Justify'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) elements.append(Paragraph(u'Η βεβαίωση αυτή χορηγείται ύστερα από αίτηση του/της ενδιαφερόμενου/ης προκειμένου να τη χρησιμοποιήσει ως δικαιολογητικό για την αναγνώριση της προϋπηρεσίας του/της.', tbl_style['Justify'])) elements.append(Paragraph(u' ', heading_style['Spacer'])) data = [] sign = os.path.join(settings.MEDIA_ROOT, "signature.png") im = Image(sign) im.drawHeight = 3.2 * cm im.drawWidth = 6.5 * cm data.append([Paragraph(u' ', signature['Center']) ,im]) table6 = Table(data, style=tsf, colWidths=[10.0 * cm, 7.0 * cm]) elements.append(table6) if emptype.order().order_type == 3: logo = os.path.join(settings.MEDIA_ROOT, "espa2.jpg") im = Image(logo) im.drawHeight = 3.0 * cm im.drawWidth = 16.3 * cm elements.append(im) elements.append(PageBreak()) doc.build(elements) return response
def imprimir(self): fec_hoy= datetime.date.today() hoy = fec_hoy.strftime("%d/%m/%Y") styleSheet=getSampleStyleSheet() img=Image("cabezalcaida.png",225,50) otro_estilo= ParagraphStyle('',fontSize = 20,textColor = '#000',leftIndent = 200,rightIndent = 50) style_barra= ParagraphStyle('',fontSize = 13,textColor = '#000',leftIndent = 300, rightIndent = 0) estilo_cabezal= ParagraphStyle('',fontSize = 15,textColor = '#000',leftIndent = 100,rightIndent = 0) texto_principal = "" estilo_texto = ParagraphStyle('', fontSize = 12, alignment = 0, spaceBefore = 0, spaceAfter = 0, #backColor = '#fff', textColor = '#999', leftIndent = 10 ) h = Paragraph(texto_principal, estilo_texto) banner = [ [ img,h ] ] options = QFileDialog.Options() story=[] ban = Table( banner, colWidths=0, rowHeights=10) story.append(ban) story.append(Spacer(0,15)) P=Paragraph("<u>Registro de ingresos diarios </u> ",estilo_cabezal) story.append(P) story.append(Spacer(0,25)) P=Paragraph("<b>Fecha: " + str (hoy)+ " </b> ",style_barra) story.append(P) story.append(Spacer(0,5)) integrantes = [[Paragraph('''<font size=12> <b> </b></font>''',styleSheet["BodyText"])], ['Nombre y Apellido', 'Cuota', 'N° Cuota','Importe', 'Punitorios','Descuento', 'Estado']] #pyqtRemoveInputHook() #import pdb; pdb.set_trace() for item in self.lst_ord: integrantes.append([str(item.nombre + ", " + item.apellido),str("cuota credito"),str(item.nro_cuota),str(round(item.monto_cobrado,2)),str(round(item.punitorios,2)), str(round(item.descuento,2)), str(item.estado_cuota)]) t=Table(integrantes, (120,65, 60, 60,75,75,50)) t.setStyle(TableStyle([ ('INNERGRID', (0,1), (-1,-1), 0.25, colors.black), ('BOX', (0,1), (-1,-1), 0.25, colors.black), ('BACKGROUND',(0,1),(-1,1),colors.lightgrey) ])) story.append(t) story.append(Spacer(0,15)) nombre_archivo = "Reg_ing_diarios" + str(datetime.date.today().year)+"_"+str(datetime.date.today().month) + "_" + str(datetime.date.today().day) + ".pdf" #---------------------------------------CAMBIAR RUTA (LA PALABRA slam2016 POR LA RUTA DESEADA DE LA PC)------------------------------------------------# file_path ="/home/slam2016/Documentos/credired/credired20170306/pdf/ingresos/ingresos"+str(datetime.date.today().year)+"_"+str(datetime.date.today().month) if not os.path.exists(file_path): os.makedirs(file_path) doc=SimpleDocTemplate(file_path +"/" + nombre_archivo) doc.build(story) if doc: msgBox = QMessageBox() msgBox.setWindowTitle("Correcto") msgBox.setText( 'Se genero el informe correctamente : ' + nombre_archivo) msgBox.exec_() if sys.platform == 'linux': subprocess.call(["xdg-open", file_path +"/" + nombre_archivo]) else: os.startfile( file_path +"/" + nombre_archivo)
from reportlab.lib.pagesizes import letter from reportlab.platypus import SimpleDocTemplate, Image, Spacer from reportlab.lib import utils img = utils.ImageReader('real-python-logo-wide.png') orig_width, height = img.getSize() aspect = height / orig_width doc = SimpleDocTemplate('watermark.pdf', pagesize=letter) logo = Image('real-python-logo-wide.png', width=400, height=400*aspect) s = Spacer doc.build([logo])
tabList.append(["time:", str(df["Time"].iloc[-1])]) tabList.append( ["Species:", ", ".join([i for i in df.columns if i != "Time"])]) tabList.append(["Reference:", newRefs[ID2]]) return Table(tabList) return Table([["fig:", ID]]) styles = getSampleStyleSheet() """ tempPar = Paragraph("test text", style = styles["Normal"]) story.append(tempPar) """ if not supressHeader: tempIm = Image(os.path.join(working_directory, "Tital Card.png")) tempIm._restrictSize(PW - 2.2 * inch, PH - 2.2 * inch) story.append(tempIm) tempIm = Image(os.path.join(working_directory, "motivation.png")) tempIm._restrictSize(PW - 2.2 * inch, PH - 2.2 * inch) story.append(tempIm) tempIm = Image(os.path.join(working_directory, "newModelHandAn.jpg")) tempIm._restrictSize(PW - 2.2 * inch, PH - 2.2 * inch) story.append(tempIm) tempIm = Image(os.path.join(working_directory, "workflow.png")) tempIm._restrictSize(PW - 2.2 * inch, PH - 2.2 * inch) story.append(tempIm)
def write_document(response, file_name, params={}): """Method to write to pdf from pandas.""" try: # datas = pd.DataFrame(data) # response = '%s.pdf' % (file_name) STATIC_ROOT = settings.STATICFILES_DIRS[0] rparams = file_name.split('_') rid = int(rparams[3]) region = rparams[0].replace('-', ' ') report_name = rparams[1].replace('-', ' ') if 'OU ' in region or 'ou_name' in params: ou_name = params['ou_name'] if 'ou_name' in params else 'DCS' report_name = "%s (%s)" % (report_name, ou_name) styles = getSampleStyleSheet() styles.add(ParagraphStyle(name='Center', alignment=TA_CENTER)) styles.add(ParagraphStyle(name='Right', alignment=TA_RIGHT)) styles.add(ParagraphStyle(name='Left', alignment=TA_LEFT)) styles.add(ParagraphStyle( name='Line_Data', alignment=TA_LEFT, fontSize=8, leading=11, fontColor='#FFFFFF')) styles.add(ParagraphStyle( name='Line_Data_Small', alignment=TA_LEFT, fontSize=7, leading=8)) styles.add(ParagraphStyle( name='Line_Data_Large', alignment=TA_LEFT, fontSize=12, leading=15)) styles.add(ParagraphStyle( name='Line_Data_Largest', alignment=TA_LEFT, fontSize=14, leading=15)) styles.add(ParagraphStyle( name='Line_Label', font='Helvetica-Bold', fontSize=7, leading=6, alignment=TA_LEFT)) styles.add(ParagraphStyle( name='Line_Label1', font='Helvetica-Bold', fontSize=7, leading=6, alignment=TA_RIGHT)) styles.add(ParagraphStyle( name='Line_Label_Center', font='Helvetica-Bold', fontSize=12, alignment=TA_CENTER)) element = [] datenow = datetime.now() tarehe = datenow.strftime("%d, %b %Y %I:%M %p") url = 'https://childprotection.go.ke' # ous = get_data(rid) # col_size = len(df.columns) # dt_size = len(df.index) # Handle headers address = '<b>MINISTRY OF LABOUR AND SOCIAL PROTECTION' address += "<br />STATE DEPARTMENT FOR SOCIAL PROTECTION" address += "<br />DEPARTMENT OF CHILDREN'S SERVICES</b>" report_number = '%s\n%s CPIMS Report\n%s' % (url, report_name, tarehe) # Work on the data start_date = '' end_date = datenow.strftime("%d, %B %Y") mon = int(datenow.strftime("%m")) year = int(datenow.strftime("%Y")) fyear = year - 1 if mon < 7 else year if rid in [1, 2, 4]: start_date = '1, July %s to ' % (fyear) dates = '%s%s' % (start_date, end_date) bar_code = BarCode(value='%s' % (report_number)) # Logo logo = "%s/img/logo_gok.png" % (STATIC_ROOT) sd = Image(logo) sd.drawHeight = 0.6 * inch sd.drawWidth = 0.7 * inch data1 = [[sd, Paragraph(address, styles["Line_Data_Large"]), Paragraph('CPIMS %s Report' % (region), styles["Line_Data_Large"]), bar_code], ['', '', Paragraph(dates, styles["Line_Label"]), '']] tt = Table( data1, colWidths=(2.1 * cm, None, 5.9 * cm, 3.4 * cm,), rowHeights=(1.2 * cm, .5 * cm,)) tt.setStyle(TableStyle([ ('INNERGRID', (2, 0), (2, 1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ])) rnote = '<b>NOTE: This is a computer generated report <br /> ' rnote += ' as at %s.</b>' % (tarehe) element.append(tt) element.append(Spacer(0.1 * cm, .2 * cm)) data1 = [[Paragraph('Report<br />Name:', styles["Line_Label"]), Paragraph(report_name, styles["Line_Data_Largest"]), Paragraph(rnote, styles["Line_Data_Small"]), ]] t0 = Table(data1, colWidths=(2 * cm, None, 6.1 * cm,)) t0.setStyle(TableStyle([ ('INNERGRID', (1, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ])) element.append(t0) # print(type(col_size), col_size) style = TableStyle( [('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.5, colors.black), ('VALIGN', (0, 0), (-1, 0), 'MIDDLE'), ('ALIGN', (2, 3), (-1, -1), 'RIGHT'), ('BACKGROUND', (0, 0), (-1, 0), '#89CFF0')]) # Configure columns flts = 0 cols, idx = get_pivot_vars(rid) # print(len(cols), len(idx), cols, idx) mflts = {} ou_id = params['ou_id'] if 'ou_id' in params else 0 if rid == 4: mflts = {'ou_id': ou_id} dfs, odf = create_pivot(rid, idx, cols, flts, mflts) # datas = np.vstack((list(dfs), np.array(dfs))).tolist() dt_size = len(dfs.index) col_size = len(dfs.columns) hdx = len(idx) rdx = len(cols) print('Size of Index / Columns', dt_size, col_size) # Now prepare the data if col_size > 2: pvt_names = list(dfs.reset_index().columns.names) dcols = {} dsize = len(dfs.columns.values) pvt_values = list(dfs.reset_index().columns.values) hd_len = len(pvt_names) # titles = list(pvt_values[0]) + pvt_names col_length = 0 for col in pvt_values: col_length = len(col) break for i in range(0, col_length): for col in pvt_values: if i not in dcols: dcols[i] = [col[i]] else: dcols[i].append(col[i]) fcls = [] for fc in dcols: fl = dcols[fc] if fc == 0: fcl = list(dict.fromkeys(fl)) nfcl = fcl + [''] * (len(fl) - len(fcl)) fcls.append(nfcl) else: fcls.append(fl) data_list = dfs.reset_index().values.tolist() # data_list = [dfs.columns.values.tolist()] + dfs.values.tolist() # print(data_list) dtl, dd = [], [] for dl in data_list: # dl[1] = Paragraph(dl[1], styles["Normal"]) if dl[0] not in dd: dd.append(dl[0]) # dl[0] = Paragraph(dl[0], styles["Normal"]) dtl.append(dl) else: dl[0] = '' dtl.append(dl) datas = fcls + dtl cols = get_rlcols(rid, dsize) # Create table style bs = col_size + (hdx - 1) ds = dt_size + (rdx) style = TableStyle( [('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.5, colors.black), ('VALIGN', (0, 0), (-1, 0), 'MIDDLE'), ('ALIGN', (hdx, hd_len), (-1, -1), 'RIGHT'), # ('FONTSIZE', (0, 0), (-1, -1), 9), ('FONTNAME', (0, ds), (-1, -1), 'Helvetica-Bold'), ('FONTNAME', (bs, 0), (-1, -1), 'Helvetica-Bold'), ('BACKGROUND', (0, 0), (-1, 0), '#89CFF0')]) t1 = Table(datas, colWidths=cols, repeatRows=hd_len) t1.setStyle(style) element.append(t1) else: ftxt = TXT[3] bfooter = Paragraph(ftxt, styles["Line_Data_Largest"]) element.append(Spacer(0.1 * cm, 1.1 * cm)) element.append(bfooter) qstyle = TableStyle( [('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.5, colors.black), ('VALIGN', (0, 0), (-1, 0), 'MIDDLE'), ('SPAN', (0, 0), (-1, 0)), ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONTNAME', (0, 0), (-1, 1), 'Helvetica-Bold'), ('BACKGROUND', (0, 0), (-1, 0), '#89CFF0')]) element.append(Spacer(0.1 * cm, 1.5 * cm)) if rid == 4 and col_size > 2: # Add case management details cmdts = get_cm(rid, ou_id) cmsize = len(cmdts.index) cmgt = "This Week's Summons, Court Sessions and Discharges" if cmsize > 0: cm_values = cmdts.values.tolist() colw = (2.86 * cm, 4.0 * cm, 1.0 * cm, 5.0 * cm, 6.0 * cm, 6.0 * cm, 3.0 * cm) data = ["CPIMS ID", "Name / Initials", "Age", "DoB", "Case Category", "Case Management", "Due Date"] cm_data = [[cmgt, "", "", "", "", "", ""], data] cm_data += cm_values else: colw = (2.86 * cm, 25.0 * cm) data = ["", "No data available from the System."] cm_data = [[cmgt, ""], data] t2 = Table(cm_data, colWidths=colw, repeatRows=2) t2.setStyle(qstyle) element.append(t2) element.append(Spacer(0.1 * cm, .5 * cm)) ftxt = TXT[1] footer = Paragraph(ftxt % (cmsize), styles["Line_Data_Small"]) element.append(footer) element.append(Spacer(0.1 * cm, .6 * cm)) # Also add DQA details qdts = get_dqa(odf) qdsize = len(qdts.index) if qdsize > 0: qa_values = qdts.values.tolist() # print(qa_values) dtitle = "DQA Records for your action" colw = (2.86 * cm, 4.0 * cm, 1.0 * cm, 5.0 * cm, 3.0 * cm, 3.0 * cm, 3.0 * cm, 3.0 * cm, 3.0 * cm) qdata = ["CPIMS ID", "Name / Initials", "Age", "Case Category", "DQA Sex", "DQA DoB", "DQA Age", "Case Status", "Case Date"] dq_data = [[dtitle, "", "", "", "", "", "", "", ""], qdata] dq_data += qa_values else: colw = (2.86 * cm, 25.0 * cm) qdata = ["", "No data available from the System."] dq_data = [["DQA Records for your action", ""], qdata] t3 = Table(dq_data, colWidths=colw, repeatRows=2) t3.setStyle(qstyle) element.append(t3) element.append(Spacer(0.1 * cm, .5 * cm)) ftxt = TXT[2] footer = Paragraph(ftxt % (qdsize), styles["Line_Data_Small"]) element.append(footer) doc = SimpleDocTemplate( response, pagesize=A4, rightMargin=20, leftMargin=20, topMargin=30, bottomMargin=30, keywords="CPIMS, Child Protection in Kenya, UNICEF, DCS, <!NMA!>") doc.pagesize = landscape(A4) # doc.build(element) doc.watermark = 'CPIMS' doc.fund_name = '' doc.report_info = '' doc.source = 'Child Protection Information Management System (CPIMS)' doc.build(element, onFirstPage=draw_page, onLaterPages=draw_page, canvasmaker=Canvas) except Exception as e: print('Error generating pdf - %s' % (e)) else: pass
sys.exit(1) try: thumbWidth = int(3 * inch) thumbHeight = int(imageHeight * (float(thumbWidth) / float(imageWidth))) imageRef.thumbnail((thumbWidth, thumbHeight), PILImage.ANTIALIAS) imageRef.save(thumbnailFile, "JPEG") except: print("Unable to save thumbnail of image file.") print("Error: %s" % sys.exc_info()[1]) sys.exit(1) Story.append(Paragraph("Image analysis report", styles["Title"])) im = Image(thumbnailFile, thumbWidth, thumbHeight) imgData = Table([ [ Paragraph("File name:", styles["Small"]), Paragraph("%s" % filename, styles["Small"]) ], [ Paragraph("File size:", styles["Small"]), Paragraph("%s kB" % (os.path.getsize(filename) / 1024), styles["Small"]) ], [ Paragraph("File MD5:", styles["Small"]), Paragraph("%s" % fileMd5(filename), styles["Small"]) ],
def create_sheet(self): styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Cassa Label')) styleSheet.add(ParagraphStyle(name='Sito Label')) styCassaLabel = styleSheet['Cassa Label'] styCassaLabel.spaceBefore = 0 styCassaLabel.spaceAfter = 0 styCassaLabel.alignment = 2 # RIGHT styCassaLabel.leading = 25 styCassaLabel.fontSize = 30 stySitoLabel = styleSheet['Sito Label'] stySitoLabel.spaceBefore = 0 stySitoLabel.spaceAfter = 0 stySitoLabel.alignment = 0 # LEFT stySitoLabel.leading = 25 stySitoLabel.fontSize = 18 stySitoLabel.fontStyle = 'bold' styNormal = styleSheet['Normal'] styNormal.spaceBefore = 10 styNormal.spaceAfter = 10 styNormal.alignment = 0 # LEFT styNormal.fontSize = 14 styNormal.leading = 15 # format labels HOME = os.environ['PYARCHINIT_HOME'] home_DB_path = '{}{}{}'.format(home, os.sep, 'pyarchinit_DB_folder') logo_path = '{}{}{}'.format(home_DB_path, os.sep, 'logo.jpg') logo = Image(logo_path) ## if test_image.drawWidth < 800: logo.drawHeight = 1.5 * inch * logo.drawHeight / logo.drawWidth logo.drawWidth = 1.5 * inch num_cassa = Paragraph("<b>N. Cassa </b>" + str(self.cassa), styCassaLabel) sito = Paragraph("<b>Sito: </b>" + str(self.sito), stySitoLabel) if self.elenco_inv_tip_rep == None: elenco_inv_tip_rep = Paragraph( "<b>Elenco N. Inv. / Tipo campione</b><br/>", styNormal) else: elenco_inv_tip_rep = Paragraph( "<b>Elenco N. Inv. / Tipo campione</b><br/>" + str(self.elenco_inv_tip_rep), styNormal) if self.elenco_us == None: elenco_us = Paragraph("<b>Elenco US/(Struttura)</b>", styNormal) else: elenco_us = Paragraph( "<b>Elenco US/(Struttura)</b><br/>" + str(self.elenco_us), styNormal) # luogo_conservazione = Paragraph("<b>Luogo di conservazione</b><br/>" + str(self.luogo_conservazione),styNormal) # schema cell_schema = [ # 00, 01, 02, 03, 04, 05, 06, 07, 08, 09 rows [logo, '01', '02', '03', '04', '05', num_cassa, '07', '08', '09'], [sito, '01', '02', '03', '04', '05', '06', '07', '08', '09'], [elenco_us, '01', '02', '03', '04', '05', '06', '07', '08', '09'], [ elenco_inv_tip_rep, '01', '02', '03', '04', '05', '06', '07', '08', '09' ] ] # table style table_style = [ ('GRID', (0, 0), (-1, -1), 0, colors.white), # ,0.0,colors.black # 0 row ('SPAN', (0, 0), (5, 0)), # elenco US ('SPAN', (6, 0), (9, 0)), # elenco US ('HALIGN', (0, 0), (9, 0), 'LEFT'), ('VALIGN', (6, 0), (9, 0), 'TOP'), ('HALIGN', (6, 0), (9, 0), 'RIGHT'), ('SPAN', (0, 1), (9, 1)), # elenco US ('HALIGN', (0, 1), (9, 1), 'LEFT'), ('SPAN', (0, 2), (9, 2)), # intestazione ('VALIGN', (0, 2), (9, 2), 'TOP'), # 1 row ('SPAN', (0, 3), (9, 3)), # elenco US ('VALIGN', (0, 3), (9, 3), 'TOP') ] colWidths = None rowHeights = None # colWidths=[80,80,80, 80,80, 80,80,80,80, 80] t = Table(cell_schema, colWidths, rowHeights, style=table_style) return t
def __converted(save_book_name, book_pages=[], filename_sort_fn=None): """ 开始转换 :param book_name: 保存的文件名(包含路径) :param book_pages: 图片数组 :param filename_sort_fn: 文件名排序规则 :return: """ # A4 纸的宽高 __a4_w, __a4_h = landscape(A4) # 对数据进行排序 if (filename_sort_fn == None): # 将按图片按名称的ASCII排序以避免错乱问题 book_pages.sort() else: # lambda 匿名函数, 第一个参数定义函数入参,第二个为参数的处理表达式 # 这样理解 # def getName(name): # return name.split("-")[1] # # 用匿名函数就这么表示 # name = lambda name:name.split("-")[1] # xname = name("haha-dd-23") # # 支持多个参数 # book_pages = sorted(book_pages, key=lambda name: int(filename_sort_fn(name))) bookPagesData = [] bookDoc = SimpleDocTemplate(save_book_name, pagesize=A4, rightMargin=72, leftMargin=72, topMargin=72, bottomMargin=18) for page in book_pages: img_w, img_h = ImageTools().getImageSize(page) # img_w = img.imageWidth # img_h = img.imageHeight if __a4_w / img_w < __a4_h / img_h: ratio = __a4_w / img_w else: ratio = __a4_h / img_h data = Image(page, img_w * ratio, img_h * ratio) bookPagesData.append(data) bookPagesData.append(PageBreak()) try: bookDoc.build(bookPagesData) # print("已转换 >>>> " + bookName) except Exception as err: print("[*][转换PDF] : 错误. [名称] > [%s]" % (save_book_name)) print("[*] Exception >>>> ", err)
Story = [] ptext = '<font size=20>%s</font>' % PDFTitle #creating the title from the enhancer name Story.append(Paragraph( ptext, styles["Normal"])) #Adding the title to the story Story.append(Spacer(2, 12)) #adding a space of one line below the title for file in os.listdir( WigfileDirectory): #list the contents of the wigfile directory #print(file) #TEST if str(file) == Wigname: #if the file is the same as the enhancer WigSnapshotimage = str(file) #make a string of the file name WigSnapshotimage_Path = "".join( [str(WigfileDirectory), "/", WigSnapshotimage]) #add the path WigSnapshotimage_object = Image(WigSnapshotimage_Path, 5 * inch, 4 * inch) #make an image object #print(WigSnapshotimage_object) # TEST Story.append(WigSnapshotimage_object) #add it to the story Story.append(Spacer(1, 12)) # add a space for insitu in os.listdir( InsituDirectory): #For each insitu in the insitu directory #print(insitu) #TEST insituName = insitu.split("_insit") insituName = insituName[0] #Obtain the insitu name #print(insituName) #TEST if str(insituName) == str( enhListElement[10] ): #if the insitu name is the same as the enhancer name Insituimage = str(insitu) #make the insitu file a string Insituimage_Path = "".join(
def get(self, request, *args, **kwargs): response = HttpResponse(content_type='application/pdf') buff = BytesIO() doc = SimpleDocTemplate(buff, pagesize=letter, rightMargin=40, leftMargin=40, topMargin=60, bottomMargin=30, title='REFERENCIA OXXO') items = [] stylo_p_center = ParagraphStyle('parrafo_center', alignment=TA_CENTER, fontSize=11, fontName="Times-Roman") stylo_p_derecha = ParagraphStyle('parrafo_center', alignment=TA_RIGHT, fontSize=11, fontName="Times-Roman") stylo_p_izquierda = ParagraphStyle('parrafo_center', alignment=TA_LEFT, fontSize=12, fontName="Times-Roman") stylo_p_center_INFO = ParagraphStyle('parrafo_center', alignment=TA_CENTER, fontSize=8, fontName="Times-Roman") stylo_p = ParagraphStyle('parrafo', alignment=TA_LEFT, fontSize=18, fontName="Times-Roman") stylo_titulo = ParagraphStyle('titulo', alignment=TA_CENTER, fontSize=14, fontName="Times-Bold") stylo_titulo_normal = ParagraphStyle('titulo', alignment=TA_CENTER, fontSize=14, fontName="Times-Roman") stylo_portada_title = ParagraphStyle('titulo', alignment=TA_CENTER, fontSize=20, fontName="Times-Bold") ord_object = Orden.objects.get(ord_order_id=self.kwargs['ord']) dta = [] items.append( Image(os.path.realpath('static/img/oxxopay1.jpg'), 8 * cm, 5 * cm)) text = """MONTO A PAGAR""" items.append(Paragraph(text, stylo_titulo)) items.append(Spacer(0, 10)) text = """${} MXN""".format(intcomma(ord_object.ord_monto)) items.append(Paragraph(text, stylo_titulo_normal)) items.append(Spacer(0, 10)) text = """OXXO Cobra una comision al momento de realizar el pago""" items.append(Paragraph(text, stylo_titulo_normal)) items.append(Spacer(0, 20)) text = """REFERENCIA""" items.append(Paragraph(text, stylo_p)) items.append(Spacer(0, 20)) text = """{}""".format(ord_object.ord_referencia) items.append(Paragraph(text, stylo_portada_title)) items.append(Spacer(0, 15)) items.append(Image(ord_object.ord_barcode_url, 5 * cm, 1.5 * cm)) items.append(Spacer(0, 30)) text = """INSTRUCCIONES""" items.append(Paragraph(text, stylo_titulo)) items.append(Spacer(0, 20)) text = """1. Acude a la tienda OXXO más cercana.""" items.append(Paragraph(text, stylo_p_izquierda)) items.append(Spacer(0, 10)) text = """2. Indica en caja que quieres realizar un pago de OXXOPay""" items.append(Paragraph(text, stylo_p_izquierda)) items.append(Spacer(0, 10)) text = """3. Dicta al cajero el número de referencia en esta ficha para que tecleé directamente en la pantalla de venta.""" items.append(Paragraph(text, stylo_p_izquierda)) items.append(Spacer(0, 10)) text = """4. Realiza el pago correspondiente con dinero en efectivo.""" items.append(Paragraph(text, stylo_p_izquierda)) items.append(Spacer(0, 10)) text = """5. Al confirmar tu pago, el cajero te entregará un comprobante impreso. En el podrás verificar que se haya realizado correctamente.Conserve este comprobante de pago.""" items.append(Paragraph(text, stylo_p_izquierda)) items.append(Spacer(0, 10)) # data_table = [( # Image(os.path.realpath('static/img/OXXO.png'), 5*cm, 5*cm), # Paragraph(text, stylo_p), # )] # tabla = Table(data_table, colWidths=[ # 15 * cm, # 5 * cm, # ]) # tabla.setStyle(TableStyle( # [ # ('GRID', (0, 0), (-1, -1), 1, colors.black), # # ('LINEBELOW', (0, 0), (-1, 0), 0, colors.darkblue), # ('BACKGROUND', (0, 0), (-1, 0), colors.transparent) # ] # )) # items.append(tabla) # items.append(Paragraph("FICHA DIGITAL NOES NECESARIO IMPRIMIR", stylo_titulo)) # items.append(Spacer(0, 20)) doc.build(items, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages) response.write(buff.getvalue()) buff.close() return response
from reportlab.platypus import Image, SimpleDocTemplate, TableStyle, Table from reportlab.lib.pagesizes import inch, A4 story = [] root_path = join( expanduser('~'), 'PycharmProjects', 'Test', 'docs', ) images = [] table_data = [] img1 = Image( join(expanduser('~'), 'PycharmProjects', 'Test', 'docs', 'test1.png'), 4 * inch, 3 * inch) # story.append(img1) images.append(img1) img2 = Image( join(expanduser('~'), 'PycharmProjects', 'Test', 'docs', 'test2.png'), 4 * inch, 3 * inch) # story.append(img2) images.append(img2) table_data.append(images) table = Table(table_data) story.append(table) doc = SimpleDocTemplate("img.pdf",
def export_courses(data): try: for i in range(0, len(data)): tmp = int(data[i][0]) LOGGER.debug(tmp) data[i][0] = convert_time(tmp) LOGGER.debug(convert_time(tmp)) doc = SimpleDocTemplate('export.pdf', rightMargin=0, leftMargin=0, topMargin=20, bottomMargin=0, pagesize=letter) elements = [] im = Image("static/ban.png", 7 * inch, 0.8 * inch) elements.append(im) styleSheet = getSampleStyleSheet() elements.append( Paragraph( '''<para fontSize="18"><br/><br/>DATE DU RELEVE : ''' + str(datetime.now().strftime("%d-%m-%Y %H:%M")) + '''<br/><br/></para>''', styleSheet["Normal"])) head = ('DATE', 'LIEU', 'LABO', 'COURSIER', 'NB_TOTAL', 'SANGUINS', 'AUTRES') heads = [head] h = Table(heads) table_style = TableStyle([ ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black), ('BOX', (0, 0), (-1, -1), 0.25, colors.black), ('FONTSIZE', (0, 0), (-1, -1), 10), ('ALIGN', (0, 0), (-1, -1), 'CENTER'), ('VALIGN', (0, 0), (-1, -1), 'TOP') ]) h.setStyle(table_style) h.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, -1), colors.green) ])) h._argW[0] = 1.3 * inch h._argW[1] = 1.5 * inch h._argW[2] = 0.7 * inch h._argW[3] = 1.5 * inch h._argW[4] = 0.9 * inch h._argW[5] = 0.9 * inch h._argW[6] = 0.9 * inch for i in range(0, len(h._argH)): h._argH[i] = 0.25 * inch elements.append(h) if not len(data) == 0: t = Table(data) t.setStyle(table_style) t._argW[0] = 1.3 * inch t._argW[1] = 1.5 * inch t._argW[2] = 0.7 * inch t._argW[3] = 1.5 * inch t._argW[4] = 0.9 * inch t._argW[5] = 0.9 * inch t._argW[6] = 0.9 * inch for i in range(0, len(t._argH)): t._argH[i] = 0.25 * inch table_style = [] for i, row in enumerate(t._argH): if i % 2 == 0: table_style.append( ('BACKGROUND', (0, i), (-1, i), colors.lightgrey)) else: table_style.append( ('BACKGROUND', (0, i), (-1, i), colors.white)) t.setStyle(TableStyle(table_style)) elements.append(t) doc.build(elements) except Exception as e: LOGGER.error("Error in export_courses(): " + str(e))
def generar_pdf(request, ubigeo, aer, aer_fin): print "generar_pdf" MARGIN_SIZE = 17 * mm PAGE_SIZE = A4 response = HttpResponse(content_type='application/pdf') response[ 'Content-Disposition'] = "attachment; filename=" + ubigeo + "001" + ".pdf" # response['Content-Disposition'] = "attachment; filename="+ubigeo+"001"+".pdf" pdf_name = "clientes.pdf" styles = getSampleStyleSheet() stylesTitle = getSampleStyleSheet() stylesCabe = getSampleStyleSheet() styleTitle = stylesTitle["Normal"] styleTitle.alignment = TA_CENTER styleBH = styles["Normal"] styleBH.alignment = TA_LEFT styleCa = stylesCabe["Normal"] styleCa.alignment = TA_CENTER buff = BytesIO() # destino = "Lista/" + str(ubigeo)+"00100"+ str(aeut)+ ".pdf" # # doc2 = SimpleDocTemplate(destino, pagesize=A4, # rightMargin=70, # leftMargin=70, # topMargin=0.5 *cm, # bottomMargin=0.5 *cm, ) doc = SimpleDocTemplate( buff, pagesize=A4, rightMargin=65, leftMargin=65, topMargin=0.5 * cm, bottomMargin=0.5 * cm, ) h_sub_tile = PS(name='Heading1', fontSize=10, leading=14, alignment=TA_CENTER) h_sub_tile_2 = PS(name='Heading1', fontSize=11, leading=14, alignment=TA_CENTER) h_center = PS(name='Heading1', fontSize=7, leading=8, alignment=TA_CENTER) h1 = PS(name='Heading1', fontSize=7, leading=8) h11 = PS(name='Heading1', fontSize=7, leading=8, alignment=TA_CENTER) h2 = PS(name='Normal', fontSize=6, leading=16) h3 = PS(name='Normal', fontSize=7, leading=14, alignment=TA_CENTER) h4 = PS(name='Normal', fontSize=6, leading=16) h5 = PS(name='Normal', fontSize=8, leading=16, alignment=TA_CENTER) h_obser = PS(name='Normal', fontSize=8, leading=16) h_bar = PS(name='Normal', fontSize=7, leading=14, alignment=TA_CENTER) story = [] distrito = Distrito.objects.get(ubigeo=ubigeo) # ubigeo # vivi = ViviendaUrbana.objects.get(ubigeo=distrito.ubigeo, zona='00100', aeu_final=aeut) # cond_viv = Aeus.objects.filter(ubigeo=distrito.ubigeo, zona='00100', aeu_final=aeut) # total = Aeus.objects.filter(ubigeo=distrito.ubigeo, zona='00100', aeu_final=aeut).count() # viv_u = ViviendaU.objects.filter(ubigeo=ubigeo) rango_equivalencia = [[1, 'A'], [2, 'B'], [3, 'C'], [4, 'D'], [5, 'E'], [6, 'F'], [7, 'G'], [8, 'H'], [9, 'I'], [10, 'J'], [11, 'K'], [12, 'L'], [13, 'M'], [14, 'N'], [15, 'O'], [16, 'P'], [17, 'Q'], [18, 'R'], [19, 'S'], [20, 'T'], [21, 'U'], [22, 'V'], [23, 'W'], [24, 'X'], [25, 'Y'], [26, 'Z']] Z1 = Paragraph( "<strong>OBSERVACIONES: .............................................................................." "....................................................................................................." "....................................................................................................." "....................................................................................................." "....................................................................................................." "....................................................................................................." "................................................................................</strong>", h_obser) table_obs = Table(data=[[Z1]], colWidths=[18.8 * cm], rowHeights=[2 * cm], style=[('GRID', (0, 0), (-1, -1), 1, colors.black)]) Z2 = Paragraph("<strong>EMPADRONADOR</strong>", h5) Z3 = Paragraph( "<strong>Todas las viviendas que estén dentro de los límites de tu A.E.U. deben ser empadronadas. Debes tener<br/>cuidado de no omitir ninguna vivienda</strong>", h5) table_empa_cuerp = Table(data=[[Z2], [Z3]], colWidths=[18.8 * cm], rowHeights=[0.7 * cm, 1.5 * cm], style=[('GRID', (0, 0), (0, 0), 1, colors.black), ('GRID', (0, 1), (0, 1), 1, colors.black), ('ALIGN', (0, 0), (0, 0), 'CENTER')]) x = 0 #caso = Seg_Esp_R_Aer.objects.filter(ubigeo=ubigeo, emp_aer=1, aer_ini_17= aer) #HABILITAR caso = Seg_Esp_R_Aer.objects.filter(ubigeo=ubigeo, aer_ini_17=aer) #BORRAR for aeu_v in caso: idaer = aeu_v.idaer idscr = aeu_v.idscr print idaer print idscr cond = Vw_Seg_Esp_R_Aer.objects.filter(idaer=idaer) x = x + 1 y = x lista_distritos = [] lista_distritos.append(ubigeo) for ubigein in range(len(lista_distritos)): if os.path.exists( "\\\srv-fileserver\\CPV2017\\list_seg_esp_rur\\" + str(lista_distritos[ubigein])) == False: os.mkdir("\\\srv-fileserver\\CPV2017\\list_seg_esp_rur\\" + str(lista_distritos[ubigein])) # for ubigein in range(tam_dis): # # if os.path.exists("\\\srv-fileserver\\CPV2017\\list_segm_esp\\" + str(lista_distritos[ubigein])) == False: # os.mkdir("\\\srv-fileserver\\CPV2017\\list_segm_esp\\" + str(lista_distritos[ubigein])) # # total_zonas = int(str(Tab_Aeus.objects.filter(ubigeo=lista_distritos[ubigein]).values_list('zona',flat=True).distinct().count())) # # for zona_t in range(total_zonas): # zoner = str(zona_t + 1).zfill(3) + "00" # listin.append(str(lista_distritos[ubigein]) + ": " + zoner + "<br/>") # if os.path.exists("\\\srv-fileserver\\CPV2017\\list_segm_esp\\" + str(lista_distritos[ubigein]) + "\\" + zoner) == False: # os.mkdir("\\\srv-fileserver\\CPV2017\\list_segm_esp\\" + str(lista_distritos[ubigein]) + "\\" + zoner) pdf = "{}-{}-{}-{}-{}.pdf".format(ubigeo, idscr[6:8], idscr[8:10], idaer[6:9], idaer[9:12]) print pdf destino = "\\\srv-fileserver\\CPV2017\\list_seg_esp_rur\\" + str( ubigeo) + "\\" + str(pdf) print destino doc2 = SimpleDocTemplate( destino, pagesize=A4, rightMargin=70, leftMargin=70, topMargin=0.5 * cm, bottomMargin=0.5 * cm, ) p = Paragraph(str(1) + " - " + str(1), h2) extra = Paragraph("-", h2) p_page = Table(data=[[extra, p]], colWidths=[17 * cm, 2.3 * cm], style=[ ('GRID', (0, 0), (-1, -1), 1, colors.white), ('ALIGN', (0, 0), (1, 0), 'RIGHT'), ]) # # string = str(ubigeo)+str(secc)+str(aeut) # st = code39.Extended39(string) # # bar_string = Paragraph(string, h_bar) pi = Paragraph("-", h2) # st_b = st # table_bar = Table( # data = [ # [pi, st_b], # ['', bar_string] # ], # colWidths= [13 * cm, 5 * cm], # style=[ # ('ALIGN', (0, 0), (-1, -1),'CENTER') # ] # ) # story.append(table_bar) viviendas_totales = Vw_Seg_Esp_R_Aer.objects.filter( Q(idaer=idaer)).order_by('or_viv_aer') total_viv = 0 secc = aeu_v.scr_ini aer = aeu_v.aer_ini_17 print secc print aer for viviendon in viviendas_totales: total_viv = total_viv + 1 data = [ ['', '', '', '', Paragraph('<strong>Doc. CPV</strong>', h4), ''], [ Paragraph('<strong>A. UBICACION GEOGRAFICA</strong>', h11), '', '', '', Paragraph('<strong>B. UBICACION CENSAL</strong>', h11), '' ], [ Paragraph('<strong>DEPARTAMENTO</strong>', h1), Paragraph(str(distrito.ccdd.ccdd), h_center), Paragraph(str(distrito.ccdd.departamento), h1), '', Paragraph('<strong>SECCIÓN Nº</strong>', h1), Paragraph('Del ' + secc + ' Al ' + secc, h1) ], [ Paragraph('<strong>PROVINCIA</strong>', h1), Paragraph(distrito.ccpp, h_center), Paragraph( str(distrito.cod_prov.provincia).decode('latin-1'), h1), '', Paragraph(str('<strong>A.E.R. Nº</strong>'), h1), Paragraph('Del ' + aer + ' Al ' + aer_fin, h1) ], [ Paragraph('<strong>DISTRITO</strong>', h1), Paragraph(distrito.ccdi, h_center), Paragraph(distrito.distrito, h1), '', '', '' ], [ '', '', '', '', Paragraph('<strong>C. TOTAL DE VIVIENDAS DEL AER.</strong>', h1), Paragraph(str(total_viv), h1) ], ] tables = Table(data, colWidths=[ 3.7 * cm, 1 * cm, 8.1 * cm, 0.3 * cm, 4.5 * cm, 2.2 * cm ]) # , # rowHeights=[0.4 * cm, 0.4 * cm, 0.4 * cm, 0.4 * cm, 0.4 * cm, 0.4 * cm, 0.7 * cm]) tables.setStyle( TableStyle([ ('TEXTCOLOR', (0, 0), (5, 0), colors.black), #('ALIGN', (4, 0), (5, 0), 'RIGHT'), #('ALIGN', (1, 2), (1, 4), 'CENTER'), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), #('GRID', (0, 1), (2, 6), 1, colors.black), #('GRID', (4, 1), (5, 4), 1, colors.black), ('GRID', (0, 1), (2, 4), 1, colors.black), ('GRID', (4, 5), (5, 6), 1, colors.black), ('GRID', (4, 1), (5, 3), 1, colors.black), ('SPAN', (0, 1), (2, 1)), ('SPAN', (4, 1), (5, 1)), ('BACKGROUND', (0, 1), (2, 1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (0, 2), (0, 4), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (4, 2), (4, 3), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (4, 5), (4, 5), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), #('BACKGROUND', (4, 1), (5, 1), colors.Color(219.0/255,229.0/255,241.0/255)), ('BACKGROUND', (4, 1), (5, 1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)) ])) t1 = Paragraph( "CENSOS NACIONALES 2017: XII DE POBLACIÓN, VII DE VIVIENDA<br/>Y III DE COMUNIDADES INDÍGENAS", h_sub_tile) t1_sub = Paragraph( "<strong>LISTADO DE CENTROS POBLADOS Y VIVIENDAS DEL ÁREA DE EMPADRONAMIENTO RURAL</strong>", h_sub_tile_2) fichero_imagen_inei = 'Reporte/Img/inei.png' imagen_logo_inei = Image(os.path.realpath(fichero_imagen_inei), width=50, height=50) P2 = Paragraph('', styleBH) fichero_imagen = 'Reporte/Img/escudo.png' imagen_logo = Image(os.path.realpath(fichero_imagen), width=50, height=50) t1_croq = Paragraph( "<strong>CROQUIS DEL ÁREA DE EMPADRONAMIENTO URBANO</strong>", h_sub_tile_2) t = Table( data=[ # ['', t1, ''], [[imagen_logo, P2], t1, [imagen_logo_inei, P2]], ['', t1_croq, ''] ], colWidths=[2 * cm, 14 * cm, 2 * cm], style=[ ('GRID', (1, 1), (-2, -2), 1, colors.white), # ('SPAN', (0, 1), (2, 1)), # ('BOX', (0, 0), (1, -1), 2, colors.black), # ('LINEABOVE', (1, 2), (-2, 2), 1, colors.blue), # ('LINEBEFORE', (2, 1), (2, -2), 1, colors.pink), # ('BACKGROUND', (0, 0), (0, 1), colors.pink), # ('BACKGROUND', (1, 1), (1, 2), colors.lavender), # ('BACKGROUND', (2, 2), (2, 3), colors.orange), # ('BOX', (0, 0), (-1, -1), 2, colors.black), ('GRID', (0, 0), (-1, -1), 0.5, colors.white), ]) obs_data = [ [ Paragraph(e, h3) for e in [ "<strong>D. INFORMACIÓN DE CENTROS POBLADOS Y VIVIENDAS</strong>", "", "", "", "", "", "", "", "", "" ] ], [ Paragraph(e, h3) for e in [ "<strong>Viv Nº</strong>", "<strong>CENTRO POBLADO</strong>", "", "", "<strong>DIRECCIÓN DE LA VIVIENDA</strong>", "", "", "", "", "<strong>Nombres y Apellidos del JEFE DE HOGAR</strong>" ] ], [ Paragraph(e, h3) for e in [ "", "<strong>CÓD.</strong>", "<strong>Or. Reg.</strong>", "<strong>Nombre</strong>", "<strong>Tipo de Vía</strong>", "<strong>Nombre de Vía</strong>", "<strong>N° de Puerta</strong>", "<strong>Piso N°</strong>", "<strong>Km. N°</strong>", "" ] ], [ Paragraph(e, h3) for e in [ "<strong>(1)</strong>", "<strong>(2)</strong>", "<strong>(3)</strong>", "<strong>(4)</strong>", "<strong>(5)</strong>", "<strong>(6)</strong>", "<strong>(7)</strong>", "<strong>(8)</strong>", "<strong>(9)</strong>", "<strong>(10)</strong>" ] ], ] c = Table(obs_data, colWidths=[ 0.9 * cm, 1.1 * cm, 1 * cm, 3.8 * cm, 1.8 * cm, 2.4 * cm, 1.1 * cm, 1 * cm, 0.9 * cm, 5.8 * cm ]) c.setStyle( TableStyle([ ('GRID', (1, 1), (-2, -2), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), #('VALIGN', (0, 0), (-1, -1), 'CENTER'), ('FONTSIZE', (0, 0), (-1, -1), 7), ('BACKGROUND', (0, 0), (-1, 0), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (0, 0), (-1, -1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('SPAN', (0, 0), (9, 0)), ('SPAN', (1, 1), (3, 1)), ('SPAN', (4, 1), (8, 1)), ('SPAN', (9, 1), (9, 2)), ('SPAN', (0, 1), (0, 2)), ('LINEBELOW', (0, 0), (-1, 0), 1, colors.black), ('BACKGROUND', (0, 0), (-1, 0), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ])) i = 0 fichero_imagen_inei = 'Reporte/Img/inei.png' imagen_logo_inei = Image(os.path.realpath(fichero_imagen_inei), width=50, height=40) P2 = Paragraph('', styleBH) fichero_imagen = 'Reporte/Img/escudo.png' imagen_logo = Image(os.path.realpath(fichero_imagen), width=50, height=50) t = Table(data=[[[imagen_logo, P2], t1, [imagen_logo_inei, P2]], ['', t1_croq, '']], colWidths=[2 * cm, 14 * cm, 2 * cm], style=[ ('GRID', (1, 1), (-2, -2), 1, colors.white), ('GRID', (0, 0), (-1, -1), 0.5, colors.white), ]) t_croq = Table(data=[[[imagen_logo, P2], t1, [imagen_logo_inei, P2]], ['', t1_sub, '']], colWidths=[2 * cm, 14 * cm, 2 * cm], style=[ ('GRID', (1, 1), (-2, -2), 1, colors.white), ('GRID', (0, 0), (-1, -1), 0.5, colors.white), ]) # story.append(t) # story.append(Spacer(0, 1 * mm)) # story.append(tables) # story.append(Spacer(0, 1 * mm)) # story.append(Spacer(0, 1 * mm)) # story.append(table_obs) # story.append(PageBreak()) # story.append(table_bar) story.append(t_croq) story.append(Spacer(0, 2 * mm)) story.append(tables) story.append(Spacer(0, 3 * mm)) story.append(c) viviendas = Vw_Seg_Esp_R_Aer.objects.filter( Q(idaer=idaer)).order_by('or_viv_aer')[0:32] total_viviendas = int( Vw_Seg_Esp_R_Aer.objects.filter( Q(idaer=idaer)).order_by('or_viv_aer').count()) for vivienda in viviendas: i = i + 1 # Bloque Listado table2 = [ (str(vivienda.or_viv_aer).decode('latin-1'), str(vivienda.codccpp).decode('latin-1'), vivienda.id_reg_or, vivienda.nomccpp, vivienda.p20_nombre, vivienda.p21, vivienda.p22_a, vivienda.p26, vivienda.p28, vivienda.p32) ] u = Table(table2, colWidths=[ 0.9 * cm, 1.1 * cm, 1 * cm, 3.8 * cm, 1.8 * cm, 2.4 * cm, 1.1 * cm, 1 * cm, 0.9 * cm, 5.8 * cm ], rowHeights=[0.5 * cm]) u.setStyle( TableStyle([ ('GRID', (1, 1), (-2, -2), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('FONTSIZE', (0, 0), (9, 0), 7), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ])) story.append(u) # viviendas_second = Vw_Seg_Esp_R_Aer.objects.filter(Q(idaer=idaer)).order_by('or_viv_aer')[32:] # if total_viviendas > 33: #num_vuelt = total_viviendas/42 #ini_val = 48 #fin_val = 47 #for i in range(num_vuelt): #ini = 32+ini_val #fin = 79+fin_val inicio = range(32, total_viviendas, 46) fin = range(80, total_viviendas, 46) nhojas = len(zip(inicio, fin)) for i in range(nhojas): #inicio_val = range(32, total_viviendas, 48) #fin_val = range(79, total_viviendas, 48) story.append(c) viviendas_second = Vw_Seg_Esp_R_Aer.objects.filter( Q(idaer=idaer)).order_by('or_viv_aer')[inicio[i]:fin[i]] for vivienda in viviendas_second: #i = i + 1 # Bloque Listado table2 = [ (str(vivienda.or_viv_aer).decode('latin-1'), str(vivienda.codccpp).decode('latin-1'), vivienda.id_reg_or, vivienda.nomccpp, vivienda.p20_nombre, vivienda.p21, vivienda.p22_a, vivienda.p26, vivienda.p28, vivienda.p32) ] u_second = Table(table2, colWidths=[ 0.9 * cm, 1.1 * cm, 1 * cm, 3.8 * cm, 1.8 * cm, 2.4 * cm, 1.1 * cm, 1 * cm, 0.9 * cm, 5.8 * cm ], rowHeights=[0.5 * cm]) u_second.setStyle( TableStyle([ ('GRID', (1, 1), (-2, -2), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('FONTSIZE', (0, 0), (9, 0), 7), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ])) story.append(u_second) #print story[4:] doc2.build(story) doc.build(story) response.write(buff.getvalue()) buff.close() return response
def get(self, request, sale_uuid): # Get sale to be printed sale = get_object_or_404(Sale, uuid=sale_uuid) # Create receipt as a Platypus story response = HttpResponse(content_type="application/pdf") response["Content-Disposition"] = f"filename=sale{sale.id}.pdf" doc = SimpleDocTemplate( response, pagesize=portrait(A4), leftMargin=2.5 * cm, rightMargin=2.5 * cm, topMargin=2.5 * cm, bottomMargin=2.5 * cm, ) styles = getSampleStyleSheet() story = [] # Festival banner if request.festival.banner: banner = Image(request.festival.banner.get_absolute_path(), width=18 * cm, height=4 * cm) banner.hAlign = 'CENTER' story.append(banner) story.append(Spacer(1, 1 * cm)) # Customer and sale number table = Table(( (Paragraph("<para><b>Customer:</b></para>", styles['Normal']), sale.customer), (Paragraph("<para><b>Sale no:</b></para>", styles['Normal']), sale.id), ), colWidths=(4 * cm, 12 * cm), hAlign='LEFT') story.append(table) story.append(Spacer(1, 0.5 * cm)) # Fringers if sale.fringers.count(): tableData = [] for fringer in sale.fringers.all(): tableData.append(("eFringer", fringer.name, fringer.description, f"£{fringer.cost}")) table = Table(tableData, colWidths=(4 * cm, 4 * cm, 4 * cm, 4 * cm), hAlign='LEFT', style=(('ALIGN', (3, 0), (3, -1), 'RIGHT'), )) story.append(table) story.append(Spacer(1, 0.5 * cm)) # Tickets if sale.tickets: is_first = True for performance in sale.performances: if not is_first: story.append(Spacer(1, 0.3 * cm)) is_first = False tableData = [] tableData.append((Paragraph( f"<para>{performance['date']:%a, %e %b} at {performance['time']:%I:%M %p} - <b>{performance['show']}</b></para>", styles['Normal']), "", "", "")) for ticket in performance['tickets']: tableData.append( (f"{ticket['id']}", "", ticket['description'], f"£{ticket['cost']}")) table = Table(tableData, colWidths=(4 * cm, 4 * cm, 4 * cm, 4 * cm), hAlign='LEFT', style=( ('SPAN', (0, 0), (3, 0)), ('ALIGN', (0, 1), (0, -1), 'RIGHT'), ('ALIGN', (3, 1), (3, -1), 'RIGHT'), )) story.append(table) story.append(Spacer(1, 0.5 * cm)) # Stripe fee table = Table( (("", Paragraph("<para><b>Card fee:</b></para>", styles['Normal']), f"£{sale.stripe_fee}"), ), colWidths=(8 * cm, 4 * cm, 4 * cm), hAlign='LEFT', style=(('ALIGN', (2, 0), (2, 0), 'RIGHT'), )) story.append(table) story.append(Spacer(1, 0.5 * cm)) # Total table = Table( (("", Paragraph("<para><b>Total:</b></para>", styles['Normal']), f"£{sale.amount}"), ), colWidths=(8 * cm, 4 * cm, 4 * cm), hAlign='LEFT', style=(('ALIGN', (2, 0), (2, 0), 'RIGHT'), )) story.append(table) # Create PDF document and return it doc.build(story) return response
def create_sheet_en(self): styleSheet = getSampleStyleSheet() styNormal = styleSheet['Normal'] styNormal.spaceBefore = 20 styNormal.spaceAfter = 20 styNormal.alignment = 0 # LEFT styleSheet = getSampleStyleSheet() styDescrizione = styleSheet['Normal'] styDescrizione.spaceBefore = 20 styDescrizione.spaceAfter = 20 styDescrizione.alignment = 4 # Justified # format labels # 0 row intestazione = Paragraph( "<b>DOCUMENTATION FORM<br/>" + str(self.datestrfdate()) + "</b>", styNormal) home = os.environ['PYARCHINIT_HOME'] conn = Connection() lo_path = conn.logo_path() lo_path_str = lo_path['logo'] home_DB_path = '{}{}{}'.format(home, os.sep, 'pyarchinit_DB_folder') if not bool(lo_path_str): logo_path = '{}{}{}'.format(home_DB_path, os.sep, 'logo.jpg') else: logo_path = lo_path_str logo = Image(logo_path) ## if test_image.drawWidth < 800: logo.drawHeight = 1.5 * inch * logo.drawHeight / logo.drawWidth logo.drawWidth = 1.5 * inch # 1 row sito = Paragraph("<b>Site</b><br/>" + str(self.sito), styNormal) nome_doc = Paragraph( "<b>Documentation name</b><br/>" + str(self.nome_doc), styNormal) data = Paragraph("<b>Date</b><br/>" + str(self.data), styNormal) # 2 row tipo_documentazione = Paragraph( "<b>Documentation type</b><br/>" + str(self.tipo_documentazione), styNormal) sorgente = Paragraph("<b>Source</b><br/>" + str(self.sorgente), styNormal) scala = Paragraph("<b>Scale</b><br/>" + str(self.scala), styNormal) # 4 row disegnatore = Paragraph("<b>Draftman</b><br/>" + str(self.disegnatore), styNormal) # 4 row note = Paragraph("<b>Note</b><br/>" + str(self.note), styDescrizione) # nr_cassa = Paragraph("<b>N° Cassa</b><br/>" + unicode(self.nr_cassa), styNormal) # schema cell_schema = [ # 00, 01, 02, 03, 04, 05, 06, 07, 08, 09 rows [ intestazione, '01', '02', '03', '04', '05', '06', logo, '08', '09' ], # 0 row ok [sito, '01', '02', '03', '04', '05', '06', '07', '08', '09'], # 1 row ok [ tipo_documentazione, '01', '02', nome_doc, '04', '05', '06', scala, '08', '09' ], # 2 row ok [note, '01', '02', '03', '04', '05', '06', '07', '08', '09'], # 3 row ok [ data, '01', '02', '03', '04', disegnatore, '06', '07', '08', '09' ] # 4 row ok ] # table style table_style = [ ('GRID', (0, 0), (-1, -1), 0.5, colors.black), # 0 row ('SPAN', (0, 0), (6, 0)), # intestazione ('SPAN', (7, 0), (9, 0)), # logo # 1 row ('SPAN', (0, 1), (9, 1)), # sito # ('SPAN', (7,1),(9,1)), #data # 2 row ('SPAN', (0, 2), (2, 2)), # tipo_documentazione ('SPAN', (3, 2), (6, 2)), # nome_doc ('SPAN', (7, 2), (9, 2)), # scala # ('VALIGN',(0,2),(9,2),'TOP'), # 3 row ('SPAN', (0, 3), (9, 3)), # note ('VALIGN', (0, 3), (9, 3), 'TOP'), # 5 row ('SPAN', (0, 4), (4, 4)), # data ('SPAN', (5, 4), (9, 4)), # disegnatore ('VALIGN', (0, 0), (-1, -1), 'TOP') ] t = Table(cell_schema, colWidths=50, rowHeights=None, style=table_style) return t
RSB = pickle.load(file) file.close() styleSheet = getSampleStyleSheet() style = styleSheet['BodyText'] styleN = styleSheet['Normal'] styleH = styleSheet['Heading1'] story = [] PW = 10 * inch PH = 5.63 * inch styles = getSampleStyleSheet() IAC = Image(os.path.join(data_dirA, "fig3Cont.png")) IAC._restrictSize((PW - 2.1 * inch) / 3, (PH - 2.1 * inch) / 2) IAGi = Image(os.path.join(data_dirA, "fig3GI.png")) IAGi._restrictSize((PW - 2.1 * inch) / 3, (PH - 2.1 * inch) / 2) IBC = Image(os.path.join(data_dirB, "fig3Cont.png")) IBC._restrictSize((PW - 2.1 * inch) / 3, (PH - 2.1 * inch) / 2) IBGi = Image(os.path.join(data_dirB, "fig3GI.png")) IBGi._restrictSize((PW - 2.1 * inch) / 3, (PH - 2.1 * inch) / 2) IO = Image(os.path.join(supAlPath, "Figure_3.jpg")) IO._restrictSize((PW - 2.1 * inch) / 3, (PH - 2.3 * inch)) myTable = Table([[IO, [IAC, IAGi], [IBC, IBGi]]], spaceAfter=inch * 0.1) myTable.setStyle( TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
def generar_pdf(request, ubigeo): print "generar_pdf" MARGIN_SIZE = 17 * mm PAGE_SIZE = A4 response = HttpResponse(content_type='application/pdf') response[ 'Content-Disposition'] = "attachment; filename=" + ubigeo + "001" + ".pdf" # response['Content-Disposition'] = "attachment; filename="+ubigeo+"001"+".pdf" pdf_name = "clientes.pdf" styles = getSampleStyleSheet() stylesTitle = getSampleStyleSheet() stylesCabe = getSampleStyleSheet() styleTitle = stylesTitle["Normal"] styleTitle.alignment = TA_CENTER styleBH = styles["Normal"] styleBH.alignment = TA_LEFT styleCa = stylesCabe["Normal"] styleCa.alignment = TA_CENTER buff = BytesIO() # destino = "Lista/" + str(ubigeo)+"00100"+ str(aeut)+ ".pdf" # # doc2 = SimpleDocTemplate(destino, pagesize=A4, # rightMargin=70, # leftMargin=70, # topMargin=0.5 *cm, # bottomMargin=0.5 *cm, ) doc = SimpleDocTemplate( buff, pagesize=A4, rightMargin=65, leftMargin=65, topMargin=0.5 * cm, bottomMargin=0.5 * cm, ) h_sub_tile = PS(name='Heading1', fontSize=10, leading=14, alignment=TA_CENTER) h_sub_tile_2 = PS(name='Heading1', fontSize=11, leading=14, alignment=TA_CENTER) h_center = PS(name='Heading1', fontSize=7, leading=8, alignment=TA_CENTER) h1 = PS(name='Heading1', fontSize=7, leading=8) h11 = PS(name='Heading1', fontSize=7, leading=8, alignment=TA_CENTER) h2 = PS(name='Normal', fontSize=6, leading=16) h3 = PS(name='Normal', fontSize=7, leading=14, alignment=TA_CENTER) h4 = PS(name='Normal', fontSize=6, leading=16) h5 = PS(name='Normal', fontSize=8, leading=16, alignment=TA_CENTER) h_obser = PS(name='Normal', fontSize=8, leading=16) h_bar = PS(name='Normal', fontSize=7, leading=14, alignment=TA_CENTER) story = [] distrito = Distrito.objects.get(ubigeo=ubigeo) # ubigeo Z1 = Paragraph( "<strong>OBSERVACIONES: .............................................................................." "....................................................................................................." "....................................................................................................." "....................................................................................................." "....................................................................................................." "....................................................................................................." "................................................................................</strong>", h_obser) table_obs = Table(data=[[Z1]], colWidths=[18.8 * cm], rowHeights=[2 * cm], style=[('GRID', (0, 0), (-1, -1), 1, colors.black)]) Z2 = Paragraph("<strong>EMPADRONADOR</strong>", h5) Z3 = Paragraph( "<strong>Todas las viviendas que estén dentro de los límites de tu A.E.U. deben ser empadronadas. Debes tener<br/>cuidado de no omitir ninguna vivienda</strong>", h5) table_empa_cuerp = Table(data=[[Z2], [Z3]], colWidths=[18.8 * cm], rowHeights=[0.7 * cm, 1.5 * cm], style=[('GRID', (0, 0), (0, 0), 1, colors.black), ('GRID', (0, 1), (0, 1), 1, colors.black), ('ALIGN', (0, 0), (0, 0), 'CENTER')]) x = 0 caso = Seg_R_Secc_Ccpp.objects.filter(ubigeo=ubigeo)[0:1] for aeu_v in caso: idaer = aeu_v.idaer idscr = aeu_v.idscr secc_ini = idscr[6:8] secc_fin = idscr[8:10] aer_ini = idaer[6:9] aer_fin = idaer[9:12] print idaer print idscr x = x + 1 lista_distritos = [] lista_distritos.append(ubigeo) for ubigein in range(len(lista_distritos)): if os.path.exists( "\\\srv-fileserver\\CPV2017\\list_seg_esp_rur\\" + str(ubigeo)) == False: os.mkdir("\\\srv-fileserver\\CPV2017\\list_seg_esp_rur\\" + str(ubigeo)) # pdf = "{}-{}-{}.pdf".format(ubigeo, idscr[6:8], idscr[8:10]) # # print pdf destino = "\\\srv-fileserver\\CPV2017\\list_seg_esp_rur\\" + str( ubigeo) + "\\" + str(ubigeo) + ".pdf" print destino doc2 = SimpleDocTemplate( destino, pagesize=A4, rightMargin=70, leftMargin=70, topMargin=0.5 * cm, bottomMargin=0.5 * cm, ) p = Paragraph(str(1) + " - " + str(1), h2) extra = Paragraph("-", h2) p_page = Table(data=[[extra, p]], colWidths=[17 * cm, 2.3 * cm], style=[ ('GRID', (0, 0), (-1, -1), 1, colors.white), ('ALIGN', (0, 0), (1, 0), 'RIGHT'), ]) # # string = str(ubigeo)+str(secc)+str(aeut) # st = code39.Extended39(string) # # bar_string = Paragraph(string, h_bar) pi = Paragraph("-", h2) # st_b = st # table_bar = Table( # data = [ # [pi, st_b], # ['', bar_string] # ], # colWidths= [13 * cm, 5 * cm], # style=[ # ('ALIGN', (0, 0), (-1, -1),'CENTER') # ] # ) # story.append(table_bar) viviendas_totales = Vw_Seg_Esp_R_Secdist_Secc.objects.filter( ubigeo=ubigeo).order_by('idscr', 'idaer', 'codccpp') total_secc_ini = Vw_Seg_Esp_R_Secdist_Secc.objects.filter( ubigeo=ubigeo).values_list('scr_ini', flat=True) total_secc_fin = Vw_Seg_Esp_R_Secdist_Secc.objects.filter( ubigeo=ubigeo).values_list('scr_fin', flat=True) cuchi_one = list(set(total_secc_ini)) cuchi_two = list(set(total_secc_fin)) secc_ini = min(cuchi_one) secc_fin = max(cuchi_two) total_aer_ini = Vw_Seg_Esp_R_Secdist_Secc.objects.filter( ubigeo=ubigeo).values_list('aer_ini', flat=True) total_aer_fin = Vw_Seg_Esp_R_Secdist_Secc.objects.filter( ubigeo=ubigeo).values_list('aer_fin', flat=True) cuchi_aer_one = list(set(total_aer_ini)) cuchi_aer_two = list(set(total_aer_fin)) aer_ini = min(cuchi_aer_one) aer_fin = max(cuchi_aer_two) total_viv = 0 for viviendon in viviendas_totales: total_viv = total_viv + viviendon.viv_ccpp data = [ ['', '', '', '', Paragraph('<strong>Doc. CPV</strong>', h4), ''], [ Paragraph('<strong>A. UBICACION GEOGRAFICA</strong>', h11), '', '', '', Paragraph('<strong>B. UBICACION CENSAL</strong>', h11), '' ], [ Paragraph('<strong>DEPARTAMENTO</strong>', h1), Paragraph(str(distrito.ccdd.ccdd), h_center), Paragraph(str(distrito.ccdd.departamento), h1), '', Paragraph('<strong>SECCIÓN Nº</strong>', h1), Paragraph('Del ' + secc_ini + ' Al ' + secc_fin, h1) ], [ Paragraph('<strong>PROVINCIA</strong>', h1), Paragraph(distrito.ccpp, h_center), Paragraph(distrito.cod_prov.provincia, h1), '', Paragraph('<strong>AER Nº</strong>', h1), Paragraph('Del ' + aer_ini + ' Al ' + aer_fin, h1) ], [ Paragraph('<strong>DISTRITO</strong>', h1), Paragraph(distrito.ccdi, h_center), Paragraph(distrito.distrito, h1), '', '', '' ], [ '', '', '', '', Paragraph( '<strong>C. TOTAL DE VIVIENDAS DEL DISTRITO.</strong>', h1), Paragraph(str(total_viv), h1) ], #Paragraph('<strong>C. TOTAL DE VIVIENDAS DEL AER.</strong>', h1) ] tables = Table(data, colWidths=[ 3.7 * cm, 1 * cm, 7.1 * cm, 0.3 * cm, 4.5 * cm, 2.2 * cm ]) # , # rowHeights=[0.4 * cm, 0.4 * cm, 0.4 * cm, 0.4 * cm, 0.4 * cm, 0.4 * cm, 0.7 * cm]) tables.setStyle( TableStyle([ ('TEXTCOLOR', (0, 0), (5, 0), colors.black), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('GRID', (0, 1), (2, 4), 1, colors.black), ('GRID', (4, 5), (5, 5), 1, colors.black), ('GRID', (4, 1), (5, 3), 1, colors.black), ('GRID', (4, 3), (5, 3), 1, colors.black), ('SPAN', (0, 1), (2, 1)), ('SPAN', (4, 1), (5, 1)), ('BACKGROUND', (0, 1), (2, 1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (0, 2), (0, 4), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (4, 1), (4, 3), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (4, 5), (4, 5), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (4, 1), (5, 1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ])) t1 = Paragraph( "CENSOS NACIONALES 2017: XII DE POBLACIÓN, VII DE VIVIENDA<br/>Y III DE COMUNIDADES INDÍGENAS", h_sub_tile) t1_sub = Paragraph( "<strong>LISTADO DE ÁREAS DE EMPADRONAMIENTO RURAL DEL DISTRO</strong>", h_sub_tile_2) fichero_imagen_inei = 'Reporte/Img/inei.png' imagen_logo_inei = Image(os.path.realpath(fichero_imagen_inei), width=50, height=50) P2 = Paragraph('', styleBH) fichero_imagen = 'Reporte/Img/escudo.png' imagen_logo = Image(os.path.realpath(fichero_imagen), width=50, height=50) t1_croq = Paragraph( "<strong>CROQUIS DEL ÁREA DE EMPADRONAMIENTO URBANO</strong>", h_sub_tile_2) t = Table( data=[ # ['', t1, ''], [[imagen_logo, P2], t1, [imagen_logo_inei, P2]], ['', t1_croq, ''] ], colWidths=[2 * cm, 14 * cm, 2 * cm], style=[ ('GRID', (1, 1), (-2, -2), 1, colors.white), ('GRID', (0, 0), (-1, -1), 0.5, colors.white), ]) obs_data = [ [ Paragraph(e, h3) for e in [ "<strong>D. INFORMACIÓN DE LAS SECCIONES CENSALES Y ÁREAS DE EMPADRONAMIENTO DEL DISTRITO</strong>", "", "", "", "", "", "" ] ], [ Paragraph(e, h3) for e in [ "<strong>SECCIÓN Nº</strong>", "<strong>AER N°</strong>", "", "<strong>CENTRO POBLADO</strong>", "", "", "<strong>N° ESTIMADOS DE VIVIENDAS</strong>" ] ], [ Paragraph(e, h3) for e in [ "", "<strong>INICIAL</strong>", "<strong>FINAL</strong>", "<strong>CÓDIGO</strong>", "<strong>NOMBRE</strong>", "<strong>CATEGORÍA</strong>", "" ] ], ] c = Table(obs_data, colWidths=[ 2 * cm, 1.7 * cm, 1.7 * cm, 1.7 * cm, 7.3 * cm, 2 * cm, 2.3 * cm ], rowHeights=[0.6 * cm, 1.1 * cm, 0.7 * cm]) c.setStyle( TableStyle([ ('GRID', (1, 1), (-2, -2), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('VALIGN', (0, 0), (-1, -1), 'CENTER'), ('FONTSIZE', (0, 0), (-1, -1), 7), ('BACKGROUND', (0, 0), (-1, 0), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (0, 0), (-1, -1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('SPAN', (0, 0), (6, 0)), ('SPAN', (1, 1), (2, 1)), ('SPAN', (3, 1), (5, 1)), ('SPAN', (0, 1), (0, 2)), ('SPAN', (6, 1), (6, 2)), ('LINEBELOW', (0, 0), (-1, 0), 1, colors.black), ('BACKGROUND', (0, 0), (-1, 0), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ])) i = 0 data_croq = [ ['', '', '', '', Paragraph('<strong>Doc. CPV</strong>', h4), ''], [ Paragraph('<strong>A. UBICACION GEOGRAFICA</strong>', h11), '', '', '', Paragraph('<strong>B. UBICACION CENSAL</strong>', h11), '' ], [ Paragraph('<strong>DEPARTAMENTO</strong>', h1), Paragraph(str(distrito.ccdd.ccdd), h_center), Paragraph(str(distrito.ccdd.departamento), h1), '', Paragraph('<strong>SECCIÓN Nº</strong>', h1), '' ], [ Paragraph('<strong>PROVINCIA</strong>', h1), Paragraph(distrito.ccpp, h_center), Paragraph( str(distrito.cod_prov.provincia).decode('latin-1'), h1), '', Paragraph(str('<strong>A.E.R. Nº</strong>'), h1), '' ], [Paragraph('<strong>DISTRITO</strong>', h1), '', '', '', '', ''], [ '', '', '', '', Paragraph('<strong>C. TOTAL DE VIVIENDAS DEL AER.</strong>', h1), '' ], ] tables_croq = Table( data_croq, colWidths=[3.7 * cm, 1 * cm, 8.3 * cm, 0.3 * cm, 4.7 * cm, 1 * cm]) tables_croq.setStyle( TableStyle([ ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('ALIGN', (1, 2), (1, 4), 'CENTER'), ('GRID', (0, 0), (2, 3), 1, colors.black), ('GRID', (4, 5), (1, 3), 1, colors.black), ('SPAN', (0, 1), (2, 1)), ('SPAN', (0, 1), (2, 1)), ('BACKGROUND', (0, 1), (-1, 1), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ('BACKGROUND', (0, 1), (0, 6), colors.Color(219.0 / 255, 229.0 / 255, 241.0 / 255)), ])) fichero_imagen_inei = 'Reporte/Img/inei.png' imagen_logo_inei = Image(os.path.realpath(fichero_imagen_inei), width=50, height=40) P2 = Paragraph('', styleBH) fichero_imagen = 'Reporte/Img/escudo.png' imagen_logo = Image(os.path.realpath(fichero_imagen), width=50, height=50) t = Table(data=[[[imagen_logo, P2], t1, [imagen_logo_inei, P2]], ['', t1_croq, '']], colWidths=[2 * cm, 14 * cm, 2 * cm], style=[ ('GRID', (1, 1), (-2, -2), 1, colors.white), ('GRID', (0, 0), (-1, -1), 0.5, colors.white), ]) t_croq = Table(data=[[[imagen_logo, P2], t1, [imagen_logo_inei, P2]], ['', t1_sub, '']], colWidths=[2 * cm, 14 * cm, 2 * cm], style=[ ('GRID', (1, 1), (-2, -2), 1, colors.white), ('GRID', (0, 0), (-1, -1), 0.5, colors.white), ]) # story.append(t) # story.append(Spacer(0, 1 * mm)) # story.append(tables) # story.append(Spacer(0, 1 * mm)) # story.append(Spacer(0, 1 * mm)) # story.append(table_obs) # story.append(PageBreak()) # story.append(table_bar) story.append(t_croq) story.append(Spacer(0, 2 * mm)) story.append(tables) story.append(Spacer(0, 3 * mm)) story.append(c) viviendas = Vw_Seg_Esp_R_Secdist_Secc.objects.filter( ubigeo=ubigeo).order_by('idscr', 'idaer', 'codccpp') #toti_viv = int(Vw_Seg_Esp_R_Secdist_Secc.objects.filter(idscr=idscr).count()) for vivienda in viviendas: if vivienda.categoria_o == None: categoria_o = '' else: categoria_o = vivienda.categoria_o i = i + 1 # Bloque Listado table2 = [(str(vivienda.scr_ini).decode('latin-1'), str(vivienda.aer_ini).decode('latin-1'), str(vivienda.aer_fin).decode('latin-1'), str(vivienda.codccpp).decode('latin-1'), vivienda.nomccpp, str(categoria_o).decode('latin-1'), str(vivienda.viv_ccpp).decode('latin-1'))] u = Table(table2, colWidths=[ 2 * cm, 1.7 * cm, 1.7 * cm, 1.7 * cm, 7.3 * cm, 2 * cm, 2.3 * cm ], rowHeights=[0.5 * cm]) u.setStyle( TableStyle([ ('GRID', (1, 1), (-2, -2), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('GRID', (0, 0), (-1, -1), 1, colors.black), ('FONTSIZE', (0, 0), (6, 0), 7), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ])) story.append(u) doc2.build(story) doc.build(story) response.write(buff.getvalue()) buff.close() return response
def __init__(self, listePersonnes=[], dictAffichage={}): """ Imprime les photos """ self.listePersonnes = listePersonnes from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, Image from reportlab.rl_config import defaultPageSize from reportlab.lib.units import inch, cm from reportlab.lib import colors from reportlab.lib.pagesizes import A4, portrait, landscape from reportlab.lib.utils import ImageReader self.hauteur_page = defaultPageSize[1] self.largeur_page = defaultPageSize[0] self.inch = inch modesPage = { 0 : { "orientation" : "portrait", "tailleImageTmp" : 3000, "tailleImageFinal" : 450, "nbreColonnes" : 1, "padding" : 20, "taille_nom" : 34, "taille_texte" : 18 }, 1 : { "orientation" : "paysage", "tailleImageTmp" : 2000, "tailleImageFinal" : 310, "nbreColonnes" : 2, "padding" : 20, "taille_nom" : 20, "taille_texte" : 12 }, 2 : { "orientation" : "portrait", "tailleImageTmp" : 2000, "tailleImageFinal" : 230, "nbreColonnes" : 2, "padding" : 10, "taille_nom" : 18, "taille_texte" : 10 }, 3 : { "orientation" : "portrait", "tailleImageTmp" : 2000, "tailleImageFinal" : 150, "nbreColonnes" : 3, "padding" : 5, "taille_nom" : 14, "taille_texte" : 8 }, 4 : { "orientation" : "portrait", "tailleImageTmp" : 2000, "tailleImageFinal" : 110, "nbreColonnes" : 4, "padding" : 5, "taille_nom" : 10, "taille_texte" : 7 }, 5 : { "orientation" : "portrait", "tailleImageTmp" : 2000, "tailleImageFinal" : 90, "nbreColonnes" : 5, "padding" : 4, "taille_nom" : 9, "taille_texte" : 6 }, } modePage = dictAffichage["disposition_page"] nbreCopies = dictAffichage["nbre_copies"] parametres = modesPage[modePage] tailleImageTmp = parametres["tailleImageTmp"] tailleImageFinal = parametres["tailleImageFinal"] nbreColonnes = parametres["nbreColonnes"] orientation = parametres["orientation"] padding = parametres["padding"] taille_nom = parametres["taille_nom"] taille_texte = parametres["taille_texte"] # Initialisation du PDF if orientation == "portrait" : taillePage = portrait(A4) else: taillePage = landscape(A4) nomDoc = UTILS_Fichiers.GetRepTemp("photoPersonnes.pdf") if "win" in sys.platform : nomDoc = nomDoc.replace("/", "\\") doc = SimpleDocTemplate(nomDoc, pagesize=taillePage) story = [] # Style du tableau styleTemp = [ #('GRID', (0,0), (-1,-1), 0.25, colors.black), # Crée la bordure noire pour tout le tableau ('VALIGN', (0,0), (-1,-1), 'TOP'), # Centre verticalement toutes les cases ('ALIGN', (0,0), (-1,-1), 'CENTRE'), # Colonne ID centrée ] ## if dictAffichage["couleur_fond"] != None : ## styleTemp.append(('BACKGROUND', (0, 0), (-1, -1), colors.black)) # Nbre de copies if nbreCopies > 1 : self.listePersonnesTmp = [] for donnees in self.listePersonnes : for x in range(0, nbreCopies) : self.listePersonnesTmp.append(donnees) self.listePersonnes = self.listePersonnesTmp self.listePersonnesTmp = [] dictPhotos = {} for IDpersonne, nom, prenom, bmp in self.listePersonnes : IDphoto, bmp = CTRL_Photo.GetPhoto(IDindividu=IDpersonne, taillePhoto=(tailleImageTmp, tailleImageTmp), qualite=100) if bmp != None : # Création de la photo dans le répertoire Temp nomFichier = UTILS_Fichiers.GetRepTemp("photoTmp%d.jpg" % IDpersonne) bmp.SaveFile(nomFichier, type=wx.BITMAP_TYPE_JPEG) img = Image(nomFichier, width=tailleImageFinal, height=tailleImageFinal) dictPhotos[IDpersonne] = img self.listePersonnesTmp.append((IDpersonne, nom, prenom)) if len(self.listePersonnesTmp) == 0 : dlg = wx.MessageDialog(None, _(u"Il n'existe aucune photo pour la ou les personnes sélectionnées !"), _(u"Mot de passe erroné"), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return # Création des largeurs de colonnes largeursColonnes = [] for numCol in range(0, nbreColonnes) : largeursColonnes.append(tailleImageFinal + (padding*2)) # Calcul du nbre de lignes du tableau nbreLignes = (len(self.listePersonnesTmp) * 1.0) / nbreColonnes if int(nbreLignes) != nbreLignes : nbreLignes = int(nbreLignes) + 1 else: nbreLignes = int(nbreLignes) # Création du tableau vide dataTableau = [] for numLigne in range(0, nbreLignes*3): ligne = [] for numCol in range(0, nbreColonnes): ligne.append("") dataTableau.append(ligne) # Remplissage du tableau index = 0 numCol = 0 numLigne = 0 for IDpersonne, nom, prenom in self.listePersonnesTmp : dataTableau[numLigne][numCol] = dictPhotos[IDpersonne] dataTableau[numLigne+1][numCol] = prenom dataTableau[numLigne+2][numCol] = FonctionsPerso.RecupTextePhotoPersonne(IDpersonne) # Style des photos styleTemp.append(('TOPPADDING', (0, numLigne), (-1, numLigne), padding)) styleTemp.append(('BOTTOMPADDING', (0, numLigne), (-1, numLigne), padding)) # Style du nom styleTemp.append(('FONT',(0, numLigne+1),(-1, numLigne+1), "Helvetica-Bold", taille_nom)) # Style du texte personnalisé styleTemp.append(('FONT',(0, numLigne+2),(-1, numLigne+2), "Helvetica", taille_texte)) styleTemp.append(('BOTTOMPADDING', (0, numLigne+2), (-1, numLigne+2), padding)) # Style de la bordure de la carte if dictAffichage["bordure"] == True : styleTemp.append(('BOX', (numCol, numLigne), (numCol, numLigne+2), 0.25, colors.black)) index += 1 if numCol < nbreColonnes-1 : numCol += 1 else: numCol = 0 numLigne += 3 style = TableStyle(styleTemp) # Création du tableau tableau = Table(dataTableau, largeursColonnes) tableau.setStyle(style) story.append(tableau) story.append(Spacer(0,20)) # Enregistrement du PDF doc.build(story) # Affichage du PDF FonctionsPerso.LanceFichierExterne(nomDoc)
def get_image(path, height=1 * cm): img = utils.ImageReader(path) iw, ih = img.getSize() aspect = ih / float(iw) return Image(path, width=(height / aspect), height=height)
def create_sheet(self): styleSheet = getSampleStyleSheet() styNormal = styleSheet['Normal'] styNormal.spaceBefore = 20 styNormal.spaceAfter = 20 styNormal.alignment = 0 # LEFT styleSheet = getSampleStyleSheet() styDescrizione = styleSheet['Normal'] styDescrizione.spaceBefore = 20 styDescrizione.spaceAfter = 20 styDescrizione.alignment = 4 # Justified # format labels # 0 row intestazione = Paragraph( "<b>SCHEDA CAMPIONI<br/>" + str(self.datestrfdate()) + "</b>", styNormal) home = os.environ['PYARCHINIT_HOME'] home_DB_path = '{}{}{}'.format(home, os.sep, 'pyarchinit_DB_folder') logo_path = '{}{}{}'.format(home_DB_path, os.sep, 'logo.jpg') logo = Image(logo_path) ## if test_image.drawWidth < 800: logo.drawHeight = 1.5 * inch * logo.drawHeight / logo.drawWidth logo.drawWidth = 1.5 * inch # 1 row sito = Paragraph("<b>Sito</b><br/>" + str(self.sito), styNormal) tipo_campione = Paragraph( "<b>Tipo Campione</b><br/>" + str(self.tipo_campione), styNormal) nr_campione = Paragraph( "<b>Nr. Campione</b><br/>" + str(self.numero_campione), styNormal) # 2 row area = Paragraph("<b>Area</b><br/>" + str(self.area), styNormal) us = Paragraph("<b>US</b><br/>" + str(self.us), styNormal) nr_inventario = Paragraph( "<b>Nr. Inventario</b><br/>" + str(self.numero_inventario), styNormal) # 4 row descrizione = Paragraph( "<b>Descrizione</b><br/>" + str(self.descrizione), styDescrizione) # 4 row luogo_conservazione = Paragraph( "<b>Luogo conservazione</b><br/>" + str(self.luogo_conservazione), styNormal) nr_cassa = Paragraph("<b>Nr. Cassa</b><br/>" + str(self.nr_cassa), styNormal) # schema cell_schema = [ # 00, 01, 02, 03, 04, 05, 06, 07, 08, 09 rows [ intestazione, '01', '02', '03', '04', '05', '06', logo, '08', '09' ], # 0 row ok [ sito, '01', '02', '03', '04', '05', '06', '07', nr_campione, '09' ], # 1 row ok [ tipo_campione, '01', '02', '03', '04', '05', '06', '07', '08' '09' ], # 2 row ok [ area, '01', '02', us, '04', '05', nr_inventario, '07', '08', '09' ], # 3 row ok [ descrizione, '01', '02', '03', '04', '05', '06', '07', '08', '09' ], # 4 row ok [ nr_cassa, '01', '02', '03', '04', '05', luogo_conservazione, '07', '08', '09' ] # 5 row ok ] # table style table_style = [ ('GRID', (0, 0), (-1, -1), 0.5, colors.black), # 0 row ('SPAN', (0, 0), (6, 0)), # intestazione ('SPAN', (7, 0), (9, 0)), # intestazione # 1 row ('SPAN', (0, 1), (7, 1)), # sito ('SPAN', (8, 1), (9, 1)), # dnr campione # 2 row ('SPAN', (0, 2), (9, 2)), # sito ('HALIGN', (0, 2), (9, 2), 'CENTER'), # 3 row ('SPAN', (0, 3), (2, 3)), # area ('SPAN', (3, 3), (5, 3)), # us ('SPAN', (6, 3), (9, 3)), # inventario ('VALIGN', (0, 3), (9, 3), 'TOP'), # 3 row ('SPAN', (0, 4), (9, 4)), # descrizione # 5 row ('SPAN', (0, 5), (5, 5)), # elementi_reperto ('SPAN', (6, 5), (9, 5)), # elementi_reperto ('VALIGN', (0, 0), (-1, -1), 'TOP') ] t = Table(cell_schema, colWidths=50, rowHeights=None, style=table_style) return t
def getFlowable(self): return Image(self.filename, self.width, self.height)
def create_sheet(self): styleSheet = getSampleStyleSheet() styNormal = styleSheet['Normal'] styNormal.spaceBefore = 20 styNormal.spaceAfter = 20 styNormal.alignment = 0 # LEFT styleSheet = getSampleStyleSheet() styDescrizione = styleSheet['Normal'] styDescrizione.spaceBefore = 20 styDescrizione.spaceAfter = 20 styDescrizione.alignment = 4 # Justified # format labels # 0 row intestazione = Paragraph( "<b>SCHEDA PERIODIZZAZIONE<br/>" + str(self.datestrfdate()) + "</b>", styNormal) if os.name == 'posix': home = os.environ['HOME'] elif os.name == 'nt': home = os.environ['HOMEPATH'] home_DB_path = ('%s%s%s') % (home, os.sep, 'pyarchinit_DB_folder') logo_path = ('%s%s%s') % (home_DB_path, os.sep, 'logo.jpg') logo = Image(logo_path) ## if test_image.drawWidth < 800: logo.drawHeight = 1.5 * inch * logo.drawHeight / logo.drawWidth logo.drawWidth = 1.5 * inch # intestazione2 = Paragraph("<b>pyArchInit</b><br/>www.pyarchinit.blogspot.com", styNormal) # 1 row sito = Paragraph("<b>Sito</b><br/>" + str(self.sito), styNormal) periodo = Paragraph("<b>Periodo</b><br/>" + str(self.periodo), styNormal) fase = Paragraph("<b>Fase</b><br/>" + str(self.fase), styNormal) # 2 row cronologia = Paragraph("<b>CRONOLOGIA</b><br/>", styNormal) # 3 row cronologia_iniziale = Paragraph( "<b>Cronologia iniziale</b><br/>" + str(self.cron_iniziale), styNormal) cronologia_finale = Paragraph( "<b>Cronologia finale</b><br/>" + str(self.cron_finale), styNormal) datazione_ext = Paragraph( "<b>Cronologia testuale</b><br/>" + str(self.datazione_estesa), styNormal) # 4 row descrizione = '' try: descrizione = Paragraph( "<b>Descrizione</b><br/>" + str(self.descrizione), styDescrizione) except: pass # schema cell_schema = [ # 00, 01, 02, 03, 04, 05, 06, 07, 08, 09 rows [ intestazione, '01', '02', '03', '04', '05', '06', logo, '08', '09' ], # 0 row ok [sito, '01', '02', '03', '04', '05', '06', '07', periodo, fase], # 1 row ok [cronologia, '01', '02', '03', '04', '05', '06', '07', '08', '09'], # 2 row ok [ cronologia_iniziale, '01', cronologia_finale, '03', datazione_ext, '05', '06', '07', '08', '09' ], # 3 row [ descrizione, '01', '02', '03', '04', '05', '06', '07', '08', '09' ] ] # 4row ok # table style table_style = [ ('GRID', (0, 0), (-1, -1), 0.5, colors.black), # 0 row ('SPAN', (0, 0), (6, 0)), # intestazione ('SPAN', (7, 0), (9, 0)), # intestazione # 1 row ('SPAN', (0, 1), (7, 1)), # Sito ('SPAN', (8, 1), (8, 1)), # periodo ('SPAN', (9, 1), (9, 1)), # fase # 2 row ('SPAN', (0, 2), (9, 2)), # intestazione cronologia # 3 row ('SPAN', (0, 3), (1, 3)), # cron iniziale ('SPAN', (2, 3), (3, 3)), # cron finale ('SPAN', (4, 3), (9, 3)), # datazione estesa # 4 ('SPAN', (0, 4), (9, 4)), # datazione estesa ('VALIGN', (0, 4), (9, 4), 'TOP'), # ('VALIGN',(5,3),(5,3),'TOP'), ('VALIGN', (0, 0), (-1, -1), 'TOP') ] t = Table(cell_schema, colWidths=50, rowHeights=None, style=table_style) return t