Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6626507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:54:02+00:00 2026-05-25T21:54:02+00:00

I am trying to convert HTML into a PDF document in Django and haven’t

  • 0

I am trying to convert HTML into a PDF document in Django and haven’t been successful.

I have tried using wkhtmltopdf 0.9.9, however Apache throws an error that wkhtmltopdf cannot connect to server. When I use wkhtmltopdf directly, it runs perfectly fine and converts the HTML into a PDF document.

I have also tried using unoconv, however the rendered PDF file doesn’t have any CSS applied to it. I have also tried using xhtml2pdf. Again I am facing same issue; the rendered PDF file doesn’t have any CSS styling applied. I have spent the better part of today and last night trying to solve this issue and I’m still no closer to solving the problem.

Let me know if you need any more information

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:54:02+00:00Added an answer on May 25, 2026 at 9:54 pm

    Configuring Pisa for Django shouldn’t be too hard.

    There are really several examples on the net that show you how to do it and
    explain how to link to external resources in your templates:

    • http://www.arnebrodowski.de/blog/501-Pisa-and-Reportlab-pitfalls.html
    • django – pisa : adding images to PDF output
    • http://antydba.blogspot.com/2009/12/django-pisa-polskie-czcionki.html
    • http://www.20seven.org/journal/2008/11/pdf-generation-with-pisa-in-django.html

    In your case you should try the link-callback-function mentioned in the first blog post:

    def fetch_resources(uri, rel):
        """
        Callback to allow pisa/reportlab to retrieve Images,Stylesheets, etc.
        `uri` is the href attribute from the html link element.
        `rel` gives a relative path, but it's not used here.
    
        """
        path = os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, ""))
        return path
    

    For newer Django-Version you probably should use STATIC_ROOT instead of MEDIA_ROOT

    Then use fetch resources accordingly in your render-method:

    pdf = pisa.pisaDocument(StringIO.StringIO(
            html.encode("UTF-8")), 
            result, 
            link_callback=fetch_resources,
            encoding="utf-8")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert an HTML file into XML file using XSLT (Using
I'm trying to convert text containing URL's into HTML anchors using Visual Basic in
I have an XML file and I'm trying convert it into a (table( HTML
I am trying to use Pagedown to convert some markdown into HTML. I have
For the longest time now I've been trying to convert HTML pages containing large
I'm trying to convert some Xaml to HTML using the .NET XslCompiledTransform and am
I am trying to convert a document with content like the following into another
I am trying to convert the code snippet given in this http://www.movable-type.co.uk/scripts/latlong.html into java.
I'm trying to convert an Excel document into a table in SQL 2005. I
I am trying to convert my jQuery script into javascript. I have a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.