2

I am new in Django I try to develop a POS system where a user clicks on a button and a PDF will print I can generate PDF but I cannot print that PDF

Here is my code where I was trying to print the PDF file

import os
    def printPDf(request, id):
    context = AuthUser.objects.filter(id=id)
    pdf = render_to_pdf('invoice.html', {'context': context})
    response = HttpResponse(pdf, content_type='application/pdf')
    os.system('lp -d HPLaserJ {0}'.format(response.strip()))
Antu
  • 2,197
  • 3
  • 25
  • 40
  • Have you gone through this page https://docs.djangoproject.com/en/2.0/howto/outputting-pdf/ ? – Shubhitgarg Oct 04 '18 at 08:14
  • That page helps me to generate PDF files using Django. but I need to print that pdf file just a single clink on a button. – Antu Oct 04 '18 at 08:28
  • Read the line containing `Content-Disposition` – Shubhitgarg Oct 04 '18 at 08:36
  • I'm new in Django and sorry to say It does not make any seance I can create a pdf file. I need to print that pdf file via a printer. would you please help me to do that with an example? – Antu Oct 04 '18 at 08:55
  • check this post this will help you i think https://stackoverflow.com/questions/51385324/printing-pdf-files-with-python – Ankit Tiwari Dec 17 '20 at 19:05

0 Answers0