diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 78ff34716..bbf96e87e 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -1784,11 +1784,13 @@ class ImpressosView(PermissionRequiredMixin, TemplateView): def gerar_pdf_impressos(request, context, template_name): template = loader.get_template(template_name) html = template.render(RequestContext(request, context)) - response = HttpResponse(content_type="application/pdf") - weasyprint.HTML( - string=html, - base_url=request.build_absolute_uri()).write_pdf( - response) + + pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri() + ).write_pdf() + + response = HttpResponse(pdf, content_type='application/pdf') + response['Content-Disposition'] = ( + 'inline; filename="relatorio_impressos.pdf"') return response diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 983ebac93..1f7ea286a 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -233,13 +233,12 @@ class ImpressosView(PermissionRequiredMixin, TemplateView): def gerar_pdf_impressos(request, context, template_name): template = loader.get_template(template_name) html = template.render(RequestContext(request, context)) - response = HttpResponse(content_type="application/pdf") - weasyprint.HTML( - string=html, - base_url=request.build_absolute_uri()).write_pdf( - response) + pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri() + ).write_pdf() - return response + response = HttpResponse(pdf, content_type='application/pdf') + response['Content-Disposition'] = ( + 'inline; filename="relatorio_impressos.pdf"') class NormaPesquisaSimplesView(PermissionRequiredMixin, FormView): form_class = NormaPesquisaSimplesForm