def print_as_pdf(request):
    context = settings.__dict__.get("_wrapped").__dict__.copy()
    person = __get_person()
    context["person"] = person
    context["print"] = True
    pdf_name = smart_str(u"%s.pdf" % person.full_name().replace(" ", "_"))
    return render_to_pdf_response("cv_as_pdf.html", context=context, pdfname=pdf_name)
Esempio n. 2
0
 def render_to_response(self, context, **response_kwargs):
     response = render_to_pdf_response('account/pdf_invoice.html',
                                       context=context)
     # debug mode: replace False with True to disable force download
     if settings.DEBUG:
         del (response._headers['content-disposition'])
     return response
Esempio n. 3
0
def print_pdf(request):
    
    i = request.GET["i"]
    arr = i.split(',')
    for nu in arr:
        pdf = render_to_pdf_response("flights/pdf.html", '', 'flight_log_' + nu + '.pdf')
        # save pdf file in server
        pdf_path = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + '/../helicopters/static/media/pdf_export/flight_log_' + nu + '.pdf'
        op = PdfFileWriter() 

        op.addBlankPage(793, 1122)
        ops = file(pdf_path, "wb")  
        op.write(ops)  
        ops.close() 
    # zip all file to one
    buffer = StringIO.StringIO()
    zf = zipfile.ZipFile(buffer, mode='w')
    for nu in arr:
        try:
            zf.write(os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + '/../helicopters/static/media/pdf_export/flight_log_' + nu + '.pdf', 'flight_log_' + nu + '.pdf')
        finally:
            pass
    zf.close()
    buffer.seek(0)
    response = HttpResponse(buffer.read())
    if(i.find(',') == -1):
        return pdf
    else:
        name = i.replace(',','')
        response['Content-Disposition'] = 'attachment; filename=flight_log_' + name + '.zip'
        response['Content-Type'] = 'application/x-zip'
        return response
Esempio n. 4
0
 def render_to_response(self, context, **response_kwargs):
     response = render_to_pdf_response('account/pdf_invoice.html',
                                       context=context)
     # debug mode: replace False with True to disable force download
     if settings.DEBUG:
         del(response._headers['content-disposition'])
     return response
Esempio n. 5
0
def imprimir(registration,request):
    payload = {'registration': registration}
    response_pdf = render_to_pdf_response('cambridge/matricula_imprimir.html', 
        payload, pdfname='cambridge-%s.pdf'%registration.id)
    response_html = render_to_response('cambridge/matricula_imprimir.html', 
        payload)
    #return response_html
    return response_pdf
Esempio n. 6
0
 def render_to_response(self, context, **response_kwargs):
     context = self.get_context_data()
     template = self.get_template_names()[0]
     resp = HttpResponse(content_type='application/pdf')
     resp['Content-Disposition'] = 'attachment; filename="{0}.pdf"'.format(
         self.get_pdf_name())
     result = render_to_pdf_response(template, context=context)
     return result
Esempio n. 7
0
def pdf(request, bbl=None):
    lot = get_object_or_404(Lot, bbl=bbl)
    lot.generate_qrcode()

    return render_to_pdf_response('lots/pdf.html', context=RequestContext(request, {
        'lot': lot,
        'base_url': BASE_URL,
        'organizers': lot.organizer_set.all(),
    }), pdfname='596acres:%s.pdf' % lot.bbl)
Esempio n. 8
0
def pdf(request, bbl=None):
    lot = get_object_or_404(Lot, bbl=bbl)
    lot.generate_qrcode()

    return render_to_pdf_response('lots/pdf.html', context=RequestContext(request, {
        'lot': lot,
        'base_url': BASE_URL,
        'organizers': lot.organizer_set.all(),
    }), pdfname='596acres:%s.pdf' % lot.bbl)
Esempio n. 9
0
def print_pdf(request):
    log_id = request.GET.get("log_id", False)
    if not log_id:
        return render(request, "flights/pdf.html", log_pdf(4))
        return HttpResponse("<html><body>please select a flight log to print</body></html>")
    # one file
    if log_id.find(",") == -1:
        # return render(request, "flights/pdf.html", log_pdf(log_id))
        log = Log.objects.get(id_log=log_id) or None
        if not log:
            return HttpResponse("<html><body>please select a flight log to print</body></html>")
        return render_to_pdf_response("flights/pdf.html", log_pdf(log_id), format6(log.log_number))
    arr = log_id.split(",")
    dirname = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/../helicopters/static/media/pdf_export/"
    pdf_files = []
    for nu in arr:
        print "-> getting Log id", nu, datetime.now().strftime("%H:%M:%S")
        log = Log.objects.get(id_log=nu) or None
        if not log:
            continue
        pdf_file = format6(log.log_number)
        pdf_files.append(pdf_file)
        try:
            # print "render_to_string ...", datetime.now().strftime('%H:%M:%S')
            pdf = render_to_string("flights/pdf.html", log_pdf(nu))
            # print "converting HtmlToPdf ...", datetime.now().strftime('%H:%M:%S')
            convertHtmlToPdf(pdf, dirname + pdf_file)
            # print "end converting HtmlToPdf ...", datetime.now().strftime('%H:%M:%S')
        except Exception as e:
            print "---------error on pdf "
            print e

    # print "zipping ...", datetime.now().strftime('%H:%M:%S')
    # zip all file to one
    buffer = StringIO.StringIO()
    zf = zipfile.ZipFile(buffer, mode="w")
    for pdf_file in pdf_files:
        try:
            zf.write(dirname + pdf_file, pdf_file)
        finally:
            pass
    zf.close()
    buffer.seek(0)
    response = HttpResponse(buffer.read())
    today_str = datetime.now().strftime("%m_%d_%Y")
    response["Content-Disposition"] = "attachment; filename=Daily_Flight_Log_" + today_str + ".zip"
    response["Content-Type"] = "application/x-zip"
    # print "end zipping ..."
    return response
Esempio n. 10
0
def test_render_response(request):
    return render_to_pdf_response('test_pdf.html')
Esempio n. 11
0
def test_render_response(request):
    return render_to_pdf_response('test_pdf.html')
Esempio n. 12
0
def pdf(request):
    filters = check_querystring(request)
    dd = get_br_context(request, filters)
    template = 'billing/index_pdf.html'
    return utils.render_to_pdf_response('billing/index_pdf.html', dd, 'invoice.pdf')
Esempio n. 13
0
def pdf_view(request):
    dd = {}
    template = 'harvard_doc/index_pdf.html'
    return utils.render_to_pdf_response(template, dd, name)