Ejemplo n.º 1
0
def generate_gbrief_png(request, id):
    data = {}
    data['letter'] = Letter.objects.get(id=id)

    if not request.user in data['letter'].owners.all():
        messages.error(request, _(u"Zugriff verweigert!"))
        return redirect_to_prev_page(request)

    # Create the HttpResponse object with the appropriate PNG headers.
    response = HttpResponse(mimetype='image/png')
    response.write(process_latex("lettr/gbrief.tex", data, type="png"))
    return response
Ejemplo n.º 2
0
def generate_gbrief_pdf(request, id):
    data = {}
    data['letter'] = Letter.objects.get(id=id)

    if not request.user in data['letter'].owners.all():
        messages.error(request, _(u"Zugriff verweigert!"))
        return redirect_to_prev_page(request)

    # Create the HttpResponse object with the appropriate PDF headers.
    response = HttpResponse(mimetype='application/pdf')
    filename = data['letter'].heading.replace(' ', '_').replace(u'ä', 'ae').replace(u"ö", "oe").replace(u'ü', 'ue').replace(u'ß', 'ss').replace(u'Ä', 'AE').replace(u'Ö', 'OE').replace(u'Ü', 'UE').encode('ascii', 'ignore')
    response['Content-Disposition'] = 'attachment; filename=%s.pdf' % filename
    response.write(process_latex("lettr/gbrief.tex", data))
    return response