Questions tagged [weasyprint]

WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. It aims to support web standards for printing.

WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. It aims to support web standards for printing. WeasyPrint is free software made available under a BSD license.

It is based on various libraries but not on a full rendering engine like WebKit or Gecko. The CSS layout engine is written in Python, designed for pagination, and meant to be easy to hack on.

Information from: http://weasyprint.org/

195 questions
15
votes
4 answers

PDF output using Weasyprint not showing images (Django)

I am trying to output PDF on Django using the Weasyprint library, but the images don't appear on the generated PDF. I have tried both relative and static URLs for the images, but even the static URL doesn't show the image. When opening the HTML…
선풍기
  • 551
  • 1
  • 4
  • 11
11
votes
1 answer

WeasyPrint page size wrong. (8.27in x 11.69 in)

I am working on a project that uses WeasyPrint to output documents. for the life of me I cannot figure out why it is defaulting the page size to a non standard page size. I would expect it to default to 8.5 x 11 inches. instead the pdfs come out as…
Nathan Tregillus
  • 5,248
  • 2
  • 43
  • 73
11
votes
2 answers

Django WeasyPrint CSS integration warning: Relative URI reference without a base URI: at line None

I want to generate reports using WeasyPrint in Django. But I don't know how to integrate the css (specifically the bootstrap css file). I am able to see the generated html. But I get a warning when I add this line to my template-
aishpant
  • 793
  • 8
  • 18
10
votes
4 answers

Python selenium test gets stuck in urlopen

My app relies on: Python 3 Django 1.8 Weasyprint Selenium It runs flawlessly on dev and production environment, but not while testing with selenium. Using weasyprint, I create a PDF from HTML, this library uses urllib to download CSS (e.g.…
SebCorbin
  • 1,344
  • 1
  • 10
  • 21
10
votes
1 answer

WeasyPrint always generating single-page PDFs from Zurb Ink

Generating a PDF from an email (Zurb Ink templated); but am always presented with a single page PDF. Runnable test-case: from weasyprint import HTML, CSS from urllib2 import urlopen if __name__ == '__main__': html =…
A T
  • 10,508
  • 14
  • 85
  • 137
10
votes
1 answer

Django-Weasyprint image issue

As it says in the docs page, I defined a img tag in my html file as follows: This url exists in the server and I even made a different view with a http response and the image is displayed just fine. Here is…
Alvaro
  • 10,389
  • 7
  • 36
  • 54
9
votes
1 answer

Install latest cairo lib in Ubuntu for weasyprint

I just installed an Ubuntu bionic instance. It comes with cairo 1.14.6 preinstalled. I need at least cairo 1.15.4 for weasyprint to work properly. Unfortunately, even after installing the latest cairo, python still picks up the old library. I would…
Josue Montano
  • 520
  • 3
  • 16
9
votes
2 answers

Generate PDF with WeasyPrint having common header/footer and pagination

I am using WeasyPrint to generate PDF in Django. I can generate pdf from a static html file like below - from django.template import Context, Template import weasyprint with open('static_file.html', 'r') as myfile: html_str =…
8
votes
3 answers

cairocffi install failed on Ubuntu 18.04

I am running pip freeze on a python project, it shows string VERSION other than numberical version and it fails the package installation, the warning message is: weasyprint 43 has requirement cairocffi>=0.9.0, but you'll have cairocffi…
Haifeng Zhang
  • 24,348
  • 16
  • 55
  • 104
8
votes
3 answers

Getting "OSError: dlopen() failed to load a library: cairo / cairo-2" on Windows

I'm getting OSError: dlopen() failed to load a library: cairo / cairo-2 when trying to execute Django after a new install. Using Windows. I'm using Weasyprint, seems to be related to that one, according to the full trace: Unhandled exception in…
SaeX
  • 13,326
  • 14
  • 67
  • 86
8
votes
1 answer

Weasyprint pdf does not fit to page

I have an html page with simple css2 rules. All of the content is contained in a div, which is 930px wide. In the browser, this looks as expected, and when printing (from chrome) it fits neatly to the page with a decent font size. Once I try to…
Eldamir
  • 8,236
  • 5
  • 36
  • 62
8
votes
1 answer

Is it possible to do fancy formatting for page footers with weasyprint?

weasyprint understands certain custom css directives, such as: @bottom-right { content: "Page " counter(page) " of " counter(pages) " } which places a "Page 1 of 4" style counter at the bottom right of each pdf page weasyprint generates. I'd…
blueberryfields
  • 35,755
  • 24
  • 82
  • 160
7
votes
1 answer

Measuring the height of text according to CSS rules – _without a browser rendering_ – for use with a virtualized list, to specify heights in advance

I've been implementing a chat client in Electron (Chrome) and React. Our top priority is speed. It behooves us, then, to use a virtualized list component (also known as "buffered render" or "window render"). We've explored react-virtualized,…
7
votes
3 answers

Only numbers are missing Weasyprint PDF

That's it, I'm on Mac Mojave with weasyprint-44, python 3.6, and Cairo etc. versions match. The PDF renders nicely otherwise - symbols and letters are fine - just no numbers? So weird. Can anyone point me in the right direction?
user2498975
  • 117
  • 12
7
votes
1 answer

Re-displaying the current heading after a page break

I'm creating a document with WeasyPrint. I have sections that have names, some of which might span across multiple pages. When a section is too long, a page break occurs. What I am trying to do is to re-display the current section's name, ideally…
Right leg
  • 13,581
  • 5
  • 36
  • 68
1
2 3
12 13