python - Pisa (XHTML -> PDF) in Django will not display images in PDF -
To start, I have seen other threads on it, and I have tried to do almost everything but it Try to fix. ..
When Pisa is used to present an HTML page for PDF, then it is clearly remembered in the pictures given in HTML. To say this, when the page is sung on HTML, everything is bound only, but when I switch the output to PDF using Pisa, the images disappear.
The most common thing I found is how to create a link callback function like this:
def fetch_resources (uri, rel): path = os.path.join (settings .MEDIA_ROOT, uri.replace (settings.MEDIA_URL, "")) return path def my_view (request, variable1): html = render_to_string ('template_goes_here.html', dict, context_instance = RequestContext (request)) Results = stringio () pdf = Pisa.pisaDocument (StringIO (html.encode ("UTF-8"), dest = result, link_callback = fetch_resources) if not pdf.err: return HttpResponse (result.getvalue (), mimetype = 'application / pdf') HttpResponse Returns ('Pisa Hates You!% S'% cgi. Run (html)) However, It does not work, PDF comes up, is great, but the images are absent.
I have also read a suggestion about HTML writing about MCustomPype, it has been converted to PDF through the command line, and then output to HTML,
I also tried to install PIL 1.1.16 instead of 1.1.17 because there is a similar problem - no dice.
Do anyone have any ideas where I am getting wrong?
It's been a while I've seen it, but I think you use lambda or funcool Will happen.
For example
link = lambda yuri, rel: os.path.join (settings.MEDIA_ROOT, uri.replace (settings.MEDIA_URL, '')) pdf = Pisa.pisaDocument (stringIo (html.encode ("UTF-8"), dest = results, link_callback = links)
Comments
Post a Comment