本文整理汇总了Python中trml2pdf.parseString函数的典型用法代码示例。如果您正苦于以下问题:Python parseString函数的具体用法?Python parseString怎么用?Python parseString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: principal
def principal(sessao,lst_materias):
arquivoPdf=str(int(time.time()*100)) + ".pdf"
tmp_data=''
tmp_data+='<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>\n'
tmp_data+='<!DOCTYPE document SYSTEM "rml.dtd">\n'
tmp_data+='<document filename="etiquetas.pdf">\n'
tmp_data+='<template pageSize="(21cm, 29.7cm)" leftMargin="2.5cm" rightMargin="2.5cm" topMargin="0.5cm" bottomMargin="0.5cm" title="Etiqueta" author="Sergio Damiati" showBoundary="0" allowSplitting="20">\n'
tmp_data+='<pageTemplate id="main">\n'
tmp_data+='<pageGraphics>\n'
tmp_data+='</pageGraphics>\n'
tmp_data+='<frame id="etiqueta" x1="3.5cm" y1="25cm" width="14cm" height="4.5cm"/>\n'
tmp_data+='<frame id="etiqueta" x1="3.5cm" y1="19.8cm" width="14cm" height="4.5cm"/>\n'
tmp_data+='<frame id="etiqueta" x1="3.5cm" y1="14.6cm" width="14cm" height="4.5cm"/>\n'
tmp_data+='<frame id="etiqueta" x1="3.5cm" y1="9.3cm" width="14cm" height="4.5cm"/>\n'
tmp_data+='<frame id="etiqueta" x1="3.5cm" y1="4.1cm" width="14cm" height="4.5cm"/>\n'
tmp_data+='<frame id="etiqueta" x1="3.5cm" y1="-1cm" width="14cm" height="4.5cm"/>\n'
tmp_data+='</pageTemplate>\n'
tmp_data+='</template>\n'
tmp_data+=paraStyle()
tmp_data+=dados(lst_materias)
tmp_data+='</document>\n'
try:
tmp_pdf=parseString(unicode(tmp_data, 'iso-8859-1'))
except:
tmp_pdf=parseString(unicode(tmp_data, 'utf-8'))
if hasattr(context.temp_folder,arquivoPdf):
context.temp_folder.manage_delObjects(ids=arquivoPdf)
context.temp_folder.manage_addFile(arquivoPdf)
arq=context.temp_folder[arquivoPdf]
arq.manage_edit(title='Arquivo PDF temporario.',filedata=tmp_pdf,content_type='application/pdf')
return "/temp_folder/"+arquivoPdf
开发者ID:cmjatai,项目名称:sapl_old,代码行数:34,代码来源:pdf_etiqueta_gerar.py
示例2: test_error_mode
def test_error_mode(self):
""" Tests that a LayoutError is raised if the onOverflow
attribute for a keepInFrame tag is set to "error" and the
content does not fit in the frame.
"""
rml = """
<!DOCTYPE document SYSTEM "rml.dtd">
<document>
<template pageSize="(8.5in, 11in)" showBoundary="1">
<pageTemplate id="main">
<frame id="i" x1="1in" y1="9in" width="2in" height="1in"/>
</pageTemplate>
</template>
<stylesheet>
</stylesheet>
<story>
<keepInFrame onOverflow="error">
<para fontSize="30">
This should raise a LayoutError!!!!!!!!!!!!
</para>
</keepInFrame>
</story>
</document>
"""
with self.assertRaises(LayoutError):
trml2pdf.parseString(rml)
开发者ID:daemondazz,项目名称:trml2pdf,代码行数:26,代码来源:test_keepinframe_tag.py
示例3: get_pdf
def get_pdf(coll_model,ent_id):
res = coll_model.find_one({"_id":utils.create_objectid(ent_id)})
t = Template(open(os.path.join(get_root_path(),'static','rml.rml')).read())
add_time = res["add_time"].split(".")[0].replace("-",".")
report_time = datetime.datetime.now().strftime('%Y.%m.%d %H:%M:%S')
_rml = t.generate(item=res,time=report_time,add_time=add_time)
rml = _rml.encode('utf-8')
name = str(time.time()).replace('.','') + "-1" + '.pdf'
uri = os.path.join(get_root_path(),'static','report',time.strftime('%Y'),time.strftime('%m-%d'),name)
if not os.path.exists(os.path.dirname(uri)):
os.makedirs(os.path.dirname(uri), mode=0777)
trml2pdf.parseString(rml,uri)
return "http://"+options.domain+uri.split("dxb")[1]
开发者ID:niyoufa,项目名称:spider,代码行数:14,代码来源:rmlpdflib.py
示例4: principal
def principal(sessao,linha1,linha2,lst_destinatarios):
"""Funcao pricipal que gera a estrutura global do arquivo rml"""
arquivoPdf=str(int(time.time()*100))+".pdf"
tmp_data=''
tmp_data+='<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp_data+='<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp_data+='<document filename="envelopes.pdf">\n'
tmp_data+='\t<template pageSize="(21cm, 29.7cm)" title="Envelopes" author="OpenLegis" allowSplitting="20" rightMargin="3mm" showBoundary="0">\n'
tmp_data+='\t\t<pageTemplate id="main">\n'
tmp_data+='\t\t<pageGraphics>\n'
tmp_data+='\t\t</pageGraphics>\n'
tmp_data+='\t\t\t<frame id="first" x1="3cm" y1="5cm" width="15cm" height="14cm"/>\n'
tmp_data+='\t\t</pageTemplate>\n'
tmp_data+='\t</template>\n'
tmp_data+=paraStyle()
tmp_data+=destinatarios(lst_destinatarios)
tmp_data+='</document>\n'
tmp_pdf=parseString(tmp_data)
if hasattr(context.temp_folder,arquivoPdf):
context.temp_folder.manage_delObjects(ids=arquivoPdf)
context.temp_folder.manage_addFile(arquivoPdf)
arq=context.temp_folder[arquivoPdf]
arq.manage_edit(title='Arquivo PDF temporário.',filedata=tmp_pdf,content_type='application/pdf')
return "/temp_folder/"+arquivoPdf
开发者ID:dgoortega,项目名称:openlegis,代码行数:28,代码来源:pdf_envelope_impresso_gerar.py
示例5: displayDoc
def displayDoc(request, id, doc):
# Create the HttpResponse object with the appropriate PDF headers for an invoice or a packing slip
order = get_object_or_404(Order, pk=id)
if doc == "invoice":
filename = "mystore-invoice.pdf"
template = "invoice.rml"
elif doc == "packingslip":
filename = "mystore-packingslip.pdf"
template = "packing-slip.rml"
elif doc == "shippinglabel":
filename = "mystore-shippinglabel.pdf"
template = "shipping-label.rml"
else:
return HttpResponseRedirect('/admin')
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=%s' % filename
shopDetails = Config.get_shop_config()
t = loader.get_template('pdf/%s' % template)
templatedir = os.path.normpath(settings.TEMPLATE_DIRS[0])
c = Context({
'filename' : filename,
'templateDir' : templatedir,
'shopDetails' : shopDetails,
'order' : order
})
pdf = trml2pdf.parseString(smart_str(t.render(c)))
response.write(pdf)
return response
开发者ID:davemerwin,项目名称:satchmo,代码行数:29,代码来源:views.py
示例6: displayDoc
def displayDoc(request, id, doc):
# Create the HttpResponse object with the appropriate PDF headers for an invoice or a packing slip
order = get_object_or_404(Order, pk=id)
shopDetails = Config.objects.get_current()
filename_prefix = shopDetails.site.domain
if doc == "invoice":
filename = "%s-invoice.pdf" % filename_prefix
template = "invoice.rml"
elif doc == "packingslip":
filename = "%s-packingslip.pdf" % filename_prefix
template = "packing-slip.rml"
elif doc == "shippinglabel":
filename = "%s-shippinglabel.pdf" % filename_prefix
template = "shipping-label.rml"
else:
return HttpResponseRedirect("/admin")
response = HttpResponse(mimetype="application/pdf")
response["Content-Disposition"] = "attachment; filename=%s" % filename
icon_uri = config_value("SHOP", "LOGO_URI")
t = loader.get_template(os.path.join("pdf", template))
c = Context(
{
"filename": filename,
"iconURI": icon_uri,
"shopDetails": shopDetails,
"order": order,
}
)
pdf = trml2pdf.parseString(smart_str(t.render(c)))
response.write(pdf)
return response
开发者ID:ToeKnee,项目名称:jelly-roll,代码行数:31,代码来源:views.py
示例7: displayDoc
def displayDoc(request, id, doc):
import trml2pdf
# Create the HttpResponse object with the appropriate PDF headers for an invoice or a packing slip
order = get_object_or_404(Order, pk=id)
shopDetails = Config.objects.get_current()
filename_prefix = shopDetails.site.domain
if doc == "invoice":
filename = "%s-invoice.pdf" % filename_prefix
template = "invoice.rml"
elif doc == "packingslip":
filename = "%s-packingslip.pdf" % filename_prefix
template = "packing-slip.rml"
elif doc == "shippinglabel":
filename = "%s-shippinglabel.pdf" % filename_prefix
template = "shipping-label.rml"
else:
return HttpResponseRedirect('/admin')
response = HttpResponse(mimetype='application/pdf')
if config_value('SHIPPING','DOWNLOAD_PDFS'):
response['Content-Disposition'] = 'attachment; filename=%s' % filename
icon_uri = config_value('SHOP', 'LOGO_URI')
t = loader.get_template(os.path.join('shop/pdf', template))
c = Context({
'filename' : filename,
'iconURI' : icon_uri,
'shopDetails' : shopDetails,
'order' : order,
'default_view_tax': config_value('TAX','DEFAULT_VIEW_TAX')
})
pdf = trml2pdf.parseString(smart_str(t.render(c)))
response.write(pdf)
return response
开发者ID:ThissDJ,项目名称:designhub,代码行数:32,代码来源:views.py
示例8: principal
def principal(sessao,imagem,data,lst_materias,dic_cabecalho,lst_rodape,dic_filtro={}):
"""Funcao principal que gera a estrutura global do arquivo rml"""
arquivoPdf=str(int(time.time()*100))+".pdf"
tmp_data=''
tmp_data+='<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp_data+='<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp_data+='<document filename="relatorio.pdf">\n'
tmp_data+='\t<template pageSize="(21cm, 29.7cm)" title="Relatorio de Materias" author="Interlegis" allowSplitting="20">\n'
tmp_data+='\t\t<pageTemplate id="first">\n'
tmp_data+='\t\t\t<pageGraphics>\n'
tmp_data+=cabecalho(dic_cabecalho,imagem)
tmp_data+=rodape(lst_rodape)
tmp_data+='\t\t\t</pageGraphics>\n'
tmp_data+='\t\t\t<frame id="first" x1="2cm" y1="4cm" width="17cm" height="21cm"/>\n'
tmp_data+='\t\t</pageTemplate>\n'
tmp_data+='\t</template>\n'
tmp_data+=paraStyle()
tmp_data+=materias(lst_materias)
tmp_data+='</document>\n'
tmp_pdf=parseString(tmp_data)
if hasattr(context.temp_folder,arquivoPdf):
context.temp_folder.manage_delObjects(ids=arquivoPdf)
context.temp_folder.manage_addFile(arquivoPdf)
arq=context.temp_folder[arquivoPdf]
arq.manage_edit(title='Arquivo PDF temporário.',filedata=tmp_pdf,content_type='application/pdf')
return "/temp_folder/"+arquivoPdf
开发者ID:cmjatai,项目名称:sapl_old,代码行数:30,代码来源:pdf_materia_gerar.py
示例9: principal
def principal(cabecalho, rodape, sessao, imagem, inf_basicas_dic):
"""
"""
arquivoPdf=str(int(time.time()*100))+".pdf"
tmp=''
tmp+='<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp+='<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp+='<document filename="relatorio.pdf">\n'
tmp+='\t<template pageSize="(21cm, 29.7cm)" title="Pauta da Sessao" author="OpenLegis" allowSplitting="20">\n'
tmp+='\t\t<pageTemplate id="first">\n'
tmp+='\t\t\t<pageGraphics>\n'
tmp+=cabecalho(inf_basicas_dic,imagem)
tmp+=rodape(rodape_dic)
tmp+='\t\t\t</pageGraphics>\n'
tmp+='\t\t\t<frame id="first" x1="2cm" y1="4cm" width="17cm" height="20.5cm"/>\n'
tmp+='\t\t</pageTemplate>\n'
tmp+='\t</template>\n'
tmp+=paraStyle()
tmp+='\t<story>\n'
tmp+=inf_basicas(inf_basicas_dic)
tmp+=expediente_materia(lst_expediente_materia)
tmp+=votacao(lst_votacao)
tmp+='\t</story>\n'
tmp+='</document>\n'
tmp_pdf=parseString(tmp)
if hasattr(context.temp_folder,arquivoPdf):
context.temp_folder.manage_delObjects(ids=arquivoPdf)
context.temp_folder.manage_addFile(arquivoPdf)
arq=context.temp_folder[arquivoPdf]
arq.manage_edit(title='Arquivo PDF temporario.',filedata=tmp_pdf,content_type='application/pdf')
return "/temp_folder/"+arquivoPdf
开发者ID:dgoortega,项目名称:openlegis,代码行数:35,代码来源:pdf_pauta_sessao_gerar.py
示例10: _run_all_examples
def _run_all_examples(self):
for name in os.listdir('.'):
if name.endswith(".rml"):
path = name # '{}/{}'.format(EXAMPLES_DIR, name)
print('running: {}'.format(path))
output = trml2pdf.parseString(open(path, "r").read())
self.assertIsNotNone(output)
开发者ID:CalPolyResDev,项目名称:trml2pdf,代码行数:7,代码来源:test_examples.py
示例11: principal
def principal(imagem, lst_materias, dic_cabecalho, lst_rodape):
"""Funcao pricipal que gera a estrutura global do arquivo rml"""
# if sessao:
# arquivoPdf=sessao+".pdf"
# else:
# arquivoPdf=str(int(time.time()*100))+".pdf"
arquivoPdf = str(int(time.time() * 100)) + ".pdf"
tmp_data = ''
tmp_data += '<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp_data += '<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp_data += '<document filename="relatorio.pdf">\n'
tmp_data += '\t<template pageSize="(21cm, 29.7cm)" title="Relatorio de Materias" author="Interlegis" allowSplitting="20">\n'
tmp_data += '\t\t<pageTemplate id="first">\n'
tmp_data += '\t\t\t<pageGraphics>\n'
tmp_data += cabecalho(dic_cabecalho, imagem)
tmp_data += rodape(lst_rodape)
tmp_data += '\t\t\t</pageGraphics>\n'
tmp_data += '\t\t\t<frame id="first" x1="2cm" y1="4cm" width="17cm" height="21cm"/>\n'
tmp_data += '\t\t</pageTemplate>\n'
tmp_data += '\t</template>\n'
tmp_data += paraStyle()
tmp_data += materias(lst_materias)
tmp_data += '</document>\n'
tmp_pdf = parseString(tmp_data)
return tmp_pdf
开发者ID:Danpeli,项目名称:sapl,代码行数:28,代码来源:pdf_espelho_gerar.py
示例12: principal
def principal(cabecalho_dic, rodape_dic, imagem, sessao, inf_basicas_dic, lst_mesa, lst_presenca_sessao, lst_expedientes, lst_expediente_materia, lst_oradores_expediente, lst_presenca_ordem_dia, lst_votacao, lst_oradores):
"""
"""
arquivoPdf = str(int(time.time() * 100)) + ".pdf"
tmp = ''
tmp += '<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp += '<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp += '<document filename="relatorio.pdf">\n'
tmp += '\t<template pageSize="(21cm, 29.7cm)" title="Sessao Plenaria" author="Interlegis" allowSplitting="20">\n'
tmp += '\t\t<pageTemplate id="first">\n'
tmp += '\t\t\t<pageGraphics>\n'
tmp += cabecalho(inf_basicas_dic, imagem)
tmp += rodape(rodape_dic)
tmp += '\t\t\t</pageGraphics>\n'
tmp += '\t\t\t<frame id="first" x1="2cm" y1="4cm" width="17cm" height="20.5cm"/>\n'
tmp += '\t\t</pageTemplate>\n'
tmp += '\t</template>\n'
tmp += paraStyle()
tmp += '\t<story>\n'
tmp += inf_basicas(inf_basicas_dic)
tmp += mesa(lst_mesa)
tmp += presenca(lst_presenca_sessao)
tmp += expedientes(lst_expedientes)
tmp += expediente_materia(lst_expediente_materia)
tmp += oradores_expediente(lst_oradores_expediente)
tmp += presenca_ordem_dia(lst_presenca_ordem_dia)
tmp += votacao(lst_votacao)
tmp += oradores(lst_oradores)
tmp += '\t</story>\n'
tmp += '</document>\n'
tmp_pdf = parseString(tmp)
return tmp_pdf
开发者ID:Danpeli,项目名称:sapl,代码行数:33,代码来源:pdf_sessao_plenaria_gerar.py
示例13: principal
def principal(sessao,imagem,data,lst_protocolos,dic_cabecalho,lst_rodape,dic_filtro={}):
"""Funcao pricipal que gera a estrutura global do arquivo rml"""
arquivoPdf=str(int(time.time()*100))+".pdf"
tmp_data=''
tmp_data+='<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp_data+='<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp_data+='<document filename="etiquetas.pdf">\n'
tmp_data+='\t<template pageSize="(62mm, 29mm)" title="Etiquetas de Protocolo" author="Luciano De Fazio" allowSplitting="20">\n'
tmp_data+='\t\t<pageTemplate id="first">\n'
tmp_data+='\t\t\t<pageGraphics>\n'
tmp_data+='\t\t\t<frame id="first" x1="0.03cm" y1="0cm" width="61mm" height="29mm"/>\n'
tmp_data+='\t\t\t</pageGraphics>\n'
tmp_data+='\t\t</pageTemplate>\n'
tmp_data+='\t</template>\n'
tmp_data+=paraStyle()
tmp_data+=protocolos(lst_protocolos)
tmp_data+='</document>\n'
tmp_pdf=parseString(tmp_data)
if hasattr(context.temp_folder,arquivoPdf):
context.temp_folder.manage_delObjects(ids=arquivoPdf)
context.temp_folder.manage_addFile(arquivoPdf)
arq=context.temp_folder[arquivoPdf]
arq.manage_edit(title='Arquivo PDF temporário.',filedata=tmp_pdf,content_type='application/pdf')
return "/temp_folder/"+arquivoPdf
开发者ID:cmjatai,项目名称:sapl_old,代码行数:28,代码来源:pdf_etiqueta_protocolo_gerar.py
示例14: write_pdf
def write_pdf(self, output):
# get plain pdf from rml
template = select_template([
'leprikon/{}/{}.rml'.format(self.pdf_export, self.subject.subject_type.slug),
'leprikon/{}/{}.rml'.format(self.pdf_export, self.subject.subject_type.subject_type),
'leprikon/{}/subject.rml'.format(self.pdf_export),
])
rml_content = template.render({
'object': self,
'site': LeprikonSite.objects.get_current(),
})
pdf_content = trml2pdf.parseString(rml_content.encode('utf-8'))
# merge with background
if self.print_setup.background:
template_pdf = PdfFileReader(self.print_setup.background.file)
registration_pdf = PdfFileReader(BytesIO(pdf_content))
writer = PdfFileWriter()
# merge pages from both template and registration
for i in range(registration_pdf.getNumPages()):
if i < template_pdf.getNumPages():
page = template_pdf.getPage(i)
page.mergePage(registration_pdf.getPage(i))
else:
page = registration_pdf.getPage(i)
writer.addPage(page)
# write result to output
writer.write(output)
else:
# write basic pdf registration to response
output.write(pdf_content)
return output
开发者ID:leprikon-cz,项目名称:leprikon,代码行数:32,代码来源:subjects.py
示例15: principal
def principal(imagem, lst_splen, lst_pauta, dic_cabecalho, lst_rodape):
"""Funcao principal que gera a estrutura global do arquivo rml contendo o relatorio de uma ordem do dia.
ordem_dia_[data da ordem do dia do relatório].pdf
Retorna:
Parâmetros:
dat_ordem => A data da ordem do dia.
splen => Uma lista de dicionários contendo as sessões plenárias do dia.
pauta => Uma lista de dicionários contendo a pauta da ordem do dia numa sessão plenária.
cabecalho => Um dicionário contendo informações para o Cabeçalho do relatório, incluindo a imagem.
rodapé => Uma lista contendo informações para o Rodapé do relatório.
"""
arquivoPdf = str(int(time.time() * 100)) + ".pdf"
tmp = ''
tmp += '<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp += '<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp += '<document filename="relatorio.pdf">\n'
tmp += '\t<template pageSize="(21cm, 29.7cm)" title="Relatorio de Materias" author="Interlegis" allowSplitting="20">\n'
tmp += '\t\t<pageTemplate id="first">\n'
tmp += '\t\t\t<pageGraphics>\n'
tmp += cabecalho(dic_cabecalho, dat_ordem, imagem)
tmp += rodape(lst_rodape)
tmp += '\t\t\t</pageGraphics>\n'
tmp += '\t\t\t<frame id="first" x1="2cm" y1="4cm" width="17cm" height="21cm"/>\n'
tmp += '\t\t</pageTemplate>\n'
tmp += '\t</template>\n'
tmp += paraStyle()
# tmp+=splen(lst_splen)
tmp += pauta(lst_splen, lst_pauta)
tmp += '</document>\n'
tmp_pdf = parseString(tmp)
return tmp_pdf
开发者ID:Danpeli,项目名称:sapl,代码行数:34,代码来源:pdf_ordem_dia_gerar.py
示例16: get
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
context.setdefault('filename', 'report.pdf')
rml = render_to_string(self.get_template_name(), context)
print(type(rml))
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = ('filename="report.pdf"')
response.write(trml2pdf.parseString(rml))
return response
开发者ID:jgsogo,项目名称:trml2pdf-issue,代码行数:10,代码来源:views.py
示例17: get
def get(self, request, *args, **kwargs):
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = ('attachment; filename="%s"'
% self.get_output_filename())
rml = render_to_string(self.get_template_names(),
self.get_context_data())
if isinstance(rml, unicode):
rml = rml.encode('UTF-8')
response.write(trml2pdf.parseString(rml))
return response
开发者ID:dashdrum,项目名称:django-reportview,代码行数:10,代码来源:views.py
示例18: gen_pdf
def gen_pdf(tmpl, ctx):
if len(settings.TEMPLATE_DIRS) > 0:
ctx['img_path'] = "%s/images/" % (settings.TEMPLATE_DIRS[0])
t = loader.get_template(tmpl)
buffer = t.render(Context(ctx)).encode('utf-8')
# no comment
buffer = buffer.replace('é', 'e')
buffer = buffer.replace('è', 'e')
buffer = buffer.replace('ô', 'o')
buffer = buffer.replace('ä', 'a')
buffer = buffer.replace('ü', 'u')
return trml2pdf.parseString(buffer)
开发者ID:RMLL,项目名称:resarmll,代码行数:12,代码来源:pdf.py
示例19: fax_report
def fax_report(request, commid=None):
fax = Fax.objects.visible_to_user(request.user).get(comm_id=commid)
from django.template import Template, Context, loader
import cStringIO
import trml2pdf
t = loader.get_template("fax/rml/comm_report.rml")
c = Context({"fax": fax})
rml = t.render(c)
buf = trml2pdf.parseString(rml)
response = HttpResponse(mimetype="application/pdf")
response.write(buf)
return response
开发者ID:puccia,项目名称:faxcelerate,代码行数:13,代码来源:views.py
示例20: principal
def principal(imagem, dic_rodape,dic_inf_basicas,dic_orig_externa,lst_mat_anexadas,lst_autoria,lst_des_iniciais,
dic_tramitacoes,lst_relatorias,lst_numeracoes,lst_leg_citadas,lst_acessorios,sessao=''):
"""
Função principal responsável por chamar as funções que irão gerar o código rml apropriado
"""
arquivoPdf=str(int(time.time()*100))+".pdf"
tmp=''
tmp+='<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
tmp+='<!DOCTYPE document SYSTEM "rml_1_0.dtd">\n'
tmp+='<document filename="relatorio.pdf">\n'
tmp+='\t<template pageSize="(21cm, 29.7cm)" title="Relatorio de Materias" author="Interlegis" allowSplitting="20">\n'
tmp+='\t\t<pageTemplate id="first">\n'
tmp+='\t\t\t<pageGraphics>\n'
tmp+=cabecalho(dic_inf_basicas,imagem)
tmp+=rodape(dic_rodape)
tmp+='\t\t\t</pageGraphics>\n'
tmp+='\t\t\t<frame id="first" x1="2cm" y1="4cm" width="17cm" height="20.5cm"/>\n'
tmp+='\t\t</pageTemplate>\n'
tmp+='\t</template>\n'
tmp+=paraStyle()
tmp+='\t<story>\n'
tmp+=inf_basicas(dic_inf_basicas)
tmp+=orig_externa(dic_orig_externa)
tmp+=mat_anexadas(lst_mat_anexadas)
tmp+=autoria(lst_autoria)
tmp+=despachos_iniciais(lst_des_iniciais)
tmp+=tramitacoes(dic_tramitacoes)
tmp+=relatorias(lst_relatorias)
tmp+=numeracoes(lst_numeracoes)
tmp+=legislacoes_citadas(lst_leg_citadas)
tmp+=documentos_acessorios(lst_acessorios)
tmp+='\t</story>\n'
tmp+='</document>\n'
tmp_pdf=parseString(tmp)
if hasattr(context.temp_folder,arquivoPdf):
context.temp_folder.manage_delObjects(ids=arquivoPdf)
context.temp_folder.manage_addFile(arquivoPdf)
arq=context.temp_folder[arquivoPdf]
arq.manage_edit(title='Arquivo PDF temporário.',filedata=tmp_pdf,content_type='application/pdf')
# try:
# tmp_pdf=parseString(unicode(tmp, 'utf-8'))
# except:
# tmp_pdf=parseString(unicode(tmp, 'utf-8'))
return "/temp_folder/"+arquivoPdf
开发者ID:cmjatai,项目名称:sapl_old,代码行数:49,代码来源:pdf_detalhe_materia_gerar.py
注:本文中的trml2pdf.parseString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论