Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Weasyprint only gives me empty pdfs when I'm trying to print newsarticles

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.25k
    Answer it
    from weasyprint import HTML
    url = ""

    The problem is that the final pdf has only part of the webpage.
    I'm assuming that this is due to the stylesheet not being part of it but how do i do that and also, is there a generic method of applying css rather than me having to apply the webpage specific stylesheet ?


 1 Answer(s)

  • Hi peterjnielsen.

    First you have to install reportlab in your system then follow the below code .

     pip install reportlab

    then you have to add python packages..
    import reportlab
    def pdf_view1(request1):
        f1 = FileSystemStorage1()
        filename = 'mypdf.pdf'
        if fs.exists(filename):
            with as pdf:
                response = HttpResponse(pdf, content_type='application1/pdf1')
                response['Content-Disposition'] = 'attachment; filename="mypdf.pdf1"'
                return response
            return HttpResponseNotFound('The requested pdf was not found in our server or can not find .')
Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: