How can i get rid my Python Flask Pdfkit error 500?

19 Views Asked by At

I've tried create pdf in new computer. In old computer, everything is fine. ut in new computer, there is error 500 (internal server error).

Here is my code:

def print_bobbin_barcode():
    master = Bobbin.query.filter_by(id=request.args.get('i', None, type=int)).first()

    code128 = barcode.get_barcode_class('code128')
    temp = code128(master.barcode, writer=ImageWriter())
    res = temp.save(r'D://Villiger//viliger//static//images//barcode//bobbin//' + str(master.barcode),
                options={"write_text": True, "text_distance": 1.0, "font_size": 13, "module_width": 0.35, "module_height": 13})

    rendered = render_template('bobbin_barcode_pdf.html', rev_doc=master.no_bukti, bobbin_no=master.no_bobbin, barcode=master.barcode)
    options = {'page-width': '50mm', 'page-height': '20mm', 'orientation': 'Portrait',
           'margin-top': '0.1mm', 'margin-bottom': '0.1mm', 'margin-left': '0.1mm', 'margin-right': '0.1mm'}
    pdf = pdfkit.from_string(rendered, False, options=options)

    response = make_response(pdf)
    response.headers["Content-Type"] = 'application/pdf'
    response.headers["Content-Disposition"] = 'inline; filename=Bobbintag Barcode - ' + str(master.no_bobbin) + '.pdf'

    return rendered

FYI, pdfkit & wkhtml2pdf alreadey installed. I am already set the path too. What am i missing?

0

There are 0 best solutions below