|
@@ -0,0 +1,244 @@
|
|
1
|
+{
|
|
2
|
+ "cells": [
|
|
3
|
+ {
|
|
4
|
+ "cell_type": "markdown",
|
|
5
|
+ "metadata": {},
|
|
6
|
+ "source": [
|
|
7
|
+ "# Collective playcard generating time!"
|
|
8
|
+ ]
|
|
9
|
+ },
|
|
10
|
+ {
|
|
11
|
+ "cell_type": "markdown",
|
|
12
|
+ "metadata": {},
|
|
13
|
+ "source": [
|
|
14
|
+ "## Git cheatsheet\n",
|
|
15
|
+ "\n",
|
|
16
|
+ "`git pull`\n",
|
|
17
|
+ "\n",
|
|
18
|
+ "`git status`\n",
|
|
19
|
+ "\n",
|
|
20
|
+ "`git log`\n",
|
|
21
|
+ "\n",
|
|
22
|
+ "`git add filename.txt`\n",
|
|
23
|
+ "\n",
|
|
24
|
+ "`git commit -m \"my short summary of what has changed\"`\n",
|
|
25
|
+ "\n",
|
|
26
|
+ "`git push`"
|
|
27
|
+ ]
|
|
28
|
+ },
|
|
29
|
+ {
|
|
30
|
+ "cell_type": "markdown",
|
|
31
|
+ "metadata": {},
|
|
32
|
+ "source": [
|
|
33
|
+ "## Generate playcard.pdf with Weasyprint"
|
|
34
|
+ ]
|
|
35
|
+ },
|
|
36
|
+ {
|
|
37
|
+ "cell_type": "markdown",
|
|
38
|
+ "metadata": {},
|
|
39
|
+ "source": [
|
|
40
|
+ "We are using Weasyprint version 52.5 on the Soupboat. The latest version is 54.1 (https://github.com/Kozea/WeasyPrint/releases), but from version 53 on [you need to have `libpango version 1.44` installed](https://github.com/Kozea/WeasyPrint/releases/tag/v53.0), and on the current version of `Raspian OS` (the operating system of the Soupboat) we can only have `libpango version 1.42`. So we will stay with [Weasyprint v52](https://github.com/Kozea/WeasyPrint/releases/tag/v52.5). \n",
|
|
41
|
+ "\n",
|
|
42
|
+ "`$ sudo pip3 install weasyprint==52.5`\n",
|
|
43
|
+ "\n",
|
|
44
|
+ "You can use Weasyprint as a Python library or from the command line."
|
|
45
|
+ ]
|
|
46
|
+ },
|
|
47
|
+ {
|
|
48
|
+ "cell_type": "markdown",
|
|
49
|
+ "metadata": {},
|
|
50
|
+ "source": [
|
|
51
|
+ "### Weasyprint as Python library"
|
|
52
|
+ ]
|
|
53
|
+ },
|
|
54
|
+ {
|
|
55
|
+ "cell_type": "code",
|
|
56
|
+ "execution_count": 19,
|
|
57
|
+ "metadata": {
|
|
58
|
+ "scrolled": true,
|
|
59
|
+ "tags": []
|
|
60
|
+ },
|
|
61
|
+ "outputs": [
|
|
62
|
+ {
|
|
63
|
+ "ename": "AttributeError",
|
|
64
|
+ "evalue": "function/symbol 'pango_context_set_round_glyph_positions' not found in library 'libpango-1.0.so.0': /lib/arm-linux-gnueabihf/libpango-1.0.so.0: undefined symbol: pango_context_set_round_glyph_positions",
|
|
65
|
+ "output_type": "error",
|
|
66
|
+ "traceback": [
|
|
67
|
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
68
|
+ "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
|
69
|
+ "\u001b[0;32m/tmp/ipykernel_22626/3089759157.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mweasyprint\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mHTML\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mCSS\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mHTML\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'playcard.html'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrite_pdf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'playcard.pdf'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstylesheets\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mCSS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'playcard.css'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
70
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/__init__.py\u001b[0m in \u001b[0;36mwrite_pdf\u001b[0;34m(self, target, stylesheets, zoom, attachments, finisher, presentational_hints, optimize_size, font_config, counter_style, image_cache)\u001b[0m\n\u001b[1;32m 184\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 185\u001b[0m \u001b[0;34m:\u001b[0m\u001b[0mtype\u001b[0m \u001b[0mtarget\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpathlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mPath\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mfile\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 186\u001b[0;31m \u001b[0;34m:\u001b[0m\u001b[0mparam\u001b[0m \u001b[0mtarget\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 187\u001b[0m \u001b[0mA\u001b[0m \u001b[0mfilename\u001b[0m \u001b[0mwhere\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mPDF\u001b[0m \u001b[0mfile\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mgenerated\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m \u001b[0mfile\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mor\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 188\u001b[0m \u001b[0;34m:\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;31m`\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
71
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/__init__.py\u001b[0m in \u001b[0;36mrender\u001b[0;34m(self, stylesheets, presentational_hints, optimize_size, font_config, counter_style, image_cache)\u001b[0m\n\u001b[1;32m 134\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mget_html_metadata\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrapper_element\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase_url\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 136\u001b[0;31m def render(self, stylesheets=None, enable_hinting=False,\n\u001b[0m\u001b[1;32m 137\u001b[0m \u001b[0mpresentational_hints\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moptimize_images\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 138\u001b[0m font_config=None, counter_style=None, image_cache=None):\n",
|
|
72
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/document.py\u001b[0m in \u001b[0;36m_render\u001b[0;34m(cls, html, stylesheets, presentational_hints, optimize_size, font_config, counter_style, image_cache)\u001b[0m\n",
|
|
73
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/document.py\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n",
|
|
74
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/__init__.py\u001b[0m in \u001b[0;36mlayout_document\u001b[0;34m(html, root_box, context, max_loops)\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpage_state\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mremake_state\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpage_data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 132\u001b[0m \u001b[0mpage_counter_values\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpage_state\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 133\u001b[0;31m \u001b[0mpage_counter_values\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'pages'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mactual_total_pages\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 134\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mremake_state\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'content_changed'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0mreloop_content\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
75
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/page.py\u001b[0m in \u001b[0;36mmake_all_pages\u001b[0;34m(context, root_box, html, pages)\u001b[0m\n",
|
|
76
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/page.py\u001b[0m in \u001b[0;36mremake_page\u001b[0;34m(index, context, root_box, html)\u001b[0m\n",
|
|
77
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/page.py\u001b[0m in \u001b[0;36mmake_page\u001b[0;34m(context, root_box, page_type, resume_at, page_number, page_state)\u001b[0m\n",
|
|
78
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_level_layout\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
79
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_level_layout_switch\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
80
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_box_layout\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
81
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_container_layout\u001b[0;34m(context, box, bottom_space, skip_stack, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
82
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36m_in_flow_layout\u001b[0;34m(context, box, index, child, new_children, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, bottom_space, position_y, skip_stack, first_letter_style, draw_bottom_decoration, collapsing_with_children, discard, next_page)\u001b[0m\n",
|
|
83
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_level_layout\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
84
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_level_layout_switch\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
85
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_box_layout\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
86
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_container_layout\u001b[0;34m(context, box, bottom_space, skip_stack, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
87
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36m_in_flow_layout\u001b[0;34m(context, box, index, child, new_children, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, bottom_space, position_y, skip_stack, first_letter_style, draw_bottom_decoration, collapsing_with_children, discard, next_page)\u001b[0m\n",
|
|
88
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_level_layout\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
89
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_level_layout_switch\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
90
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_box_layout\u001b[0;34m(context, box, bottom_space, skip_stack, containing_block, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
91
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36mblock_container_layout\u001b[0;34m(context, box, bottom_space, skip_stack, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, discard)\u001b[0m\n",
|
|
92
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/block.py\u001b[0m in \u001b[0;36m_linebox_layout\u001b[0;34m(context, box, index, child, new_children, page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins, bottom_space, position_y, skip_stack, first_letter_style, draw_bottom_decoration)\u001b[0m\n",
|
|
93
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/inline.py\u001b[0m in \u001b[0;36miter_line_boxes\u001b[0;34m(context, box, position_y, bottom_space, skip_stack, containing_block, absolute_boxes, fixed_boxes, first_letter_style)\u001b[0m\n",
|
|
94
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/inline.py\u001b[0m in \u001b[0;36mget_next_linebox\u001b[0;34m(context, linebox, position_y, bottom_space, skip_stack, containing_block, absolute_boxes, fixed_boxes, first_letter_style)\u001b[0m\n",
|
|
95
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/inline.py\u001b[0m in \u001b[0;36msplit_inline_box\u001b[0;34m(context, box, position_x, max_x, bottom_space, skip_stack, containing_block, absolute_boxes, fixed_boxes, line_placeholders, waiting_floats, line_children)\u001b[0m\n",
|
|
96
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/inline.py\u001b[0m in \u001b[0;36msplit_inline_level\u001b[0;34m(context, box, position_x, max_x, bottom_space, skip_stack, containing_block, absolute_boxes, fixed_boxes, line_placeholders, waiting_floats, line_children)\u001b[0m\n",
|
|
97
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/layout/inline.py\u001b[0m in \u001b[0;36msplit_text_box\u001b[0;34m(context, box, available_width, skip)\u001b[0m\n",
|
|
98
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/text/line_break.py\u001b[0m in \u001b[0;36msplit_first_line\u001b[0;34m(text, style, context, max_width, justification_spacing, minimum)\u001b[0m\n",
|
|
99
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/text/line_break.py\u001b[0m in \u001b[0;36mcreate_layout\u001b[0;34m(text, style, context, max_width, justification_spacing)\u001b[0m\n",
|
|
100
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/text/line_break.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, context, font_size, style, justification_spacing, max_width)\u001b[0m\n",
|
|
101
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/text/line_break.py\u001b[0m in \u001b[0;36msetup\u001b[0;34m(self, context, font_size, style)\u001b[0m\n",
|
|
102
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/cffi/api.py\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 910\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mFFILibrary\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 911\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__getattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 912\u001b[0;31m \u001b[0mmake_accessor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 913\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 914\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
103
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/cffi/api.py\u001b[0m in \u001b[0;36mmake_accessor\u001b[0;34m(name)\u001b[0m\n\u001b[1;32m 906\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0maccessors\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 907\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 908\u001b[0;31m \u001b[0maccessors\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 909\u001b[0m \u001b[0;31m#\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 910\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mFFILibrary\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
104
|
+ "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/cffi/api.py\u001b[0m in \u001b[0;36maccessor_function\u001b[0;34m(name)\u001b[0m\n\u001b[1;32m 836\u001b[0m \u001b[0mtp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mffi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_declarations\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 837\u001b[0m \u001b[0mBType\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mffi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_cached_btype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 838\u001b[0;31m \u001b[0mvalue\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbackendlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mBType\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 839\u001b[0m \u001b[0mlibrary\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__dict__\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 840\u001b[0m \u001b[0;31m#\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
105
|
+ "\u001b[0;31mAttributeError\u001b[0m: function/symbol 'pango_context_set_round_glyph_positions' not found in library 'libpango-1.0.so.0': /lib/arm-linux-gnueabihf/libpango-1.0.so.0: undefined symbol: pango_context_set_round_glyph_positions"
|
|
106
|
+ ]
|
|
107
|
+ }
|
|
108
|
+ ],
|
|
109
|
+ "source": [
|
|
110
|
+ "from weasyprint import HTML, CSS\n",
|
|
111
|
+ "\n",
|
|
112
|
+ "HTML(filename='playcard.html').write_pdf('playcard.pdf', stylesheets=[CSS(filename='playcard.css')])"
|
|
113
|
+ ]
|
|
114
|
+ },
|
|
115
|
+ {
|
|
116
|
+ "cell_type": "markdown",
|
|
117
|
+ "metadata": {},
|
|
118
|
+ "source": [
|
|
119
|
+ "### Weasyprint from the command line"
|
|
120
|
+ ]
|
|
121
|
+ },
|
|
122
|
+ {
|
|
123
|
+ "cell_type": "code",
|
|
124
|
+ "execution_count": 16,
|
|
125
|
+ "metadata": {
|
|
126
|
+ "scrolled": true,
|
|
127
|
+ "tags": []
|
|
128
|
+ },
|
|
129
|
+ "outputs": [
|
|
130
|
+ {
|
|
131
|
+ "name": "stdout",
|
|
132
|
+ "output_type": "stream",
|
|
133
|
+ "text": [
|
|
134
|
+ "usage: weasyprint [-h] [--version] [-i] [-e ENCODING] [-s STYLESHEET]\n",
|
|
135
|
+ " [-m MEDIA_TYPE] [-u BASE_URL] [-a ATTACHMENT] [-p]\n",
|
|
136
|
+ " [-O {images,fonts,all,none}] [-v] [-d] [-q]\n",
|
|
137
|
+ " input output\n",
|
|
138
|
+ "\n",
|
|
139
|
+ "Renders web pages to PDF.\n",
|
|
140
|
+ "\n",
|
|
141
|
+ "positional arguments:\n",
|
|
142
|
+ " input URL or filename of the HTML input, or - for stdin\n",
|
|
143
|
+ " output Filename where output is written, or - for stdout\n",
|
|
144
|
+ "\n",
|
|
145
|
+ "optional arguments:\n",
|
|
146
|
+ " -h, --help show this help message and exit\n",
|
|
147
|
+ " --version Print WeasyPrint's version number and exit.\n",
|
|
148
|
+ " -i, --info Print system information and exit.\n",
|
|
149
|
+ " -e ENCODING, --encoding ENCODING\n",
|
|
150
|
+ " Character encoding of the input\n",
|
|
151
|
+ " -s STYLESHEET, --stylesheet STYLESHEET\n",
|
|
152
|
+ " URL or filename for a user CSS stylesheet. May be\n",
|
|
153
|
+ " given multiple times.\n",
|
|
154
|
+ " -m MEDIA_TYPE, --media-type MEDIA_TYPE\n",
|
|
155
|
+ " Media type to use for @media, defaults to print\n",
|
|
156
|
+ " -u BASE_URL, --base-url BASE_URL\n",
|
|
157
|
+ " Base for relative URLs in the HTML input. Defaults to\n",
|
|
158
|
+ " the input's own filename or URL or the current\n",
|
|
159
|
+ " directory for stdin.\n",
|
|
160
|
+ " -a ATTACHMENT, --attachment ATTACHMENT\n",
|
|
161
|
+ " URL or filename of a file to attach to the PDF\n",
|
|
162
|
+ " document\n",
|
|
163
|
+ " -p, --presentational-hints\n",
|
|
164
|
+ " Follow HTML presentational hints.\n",
|
|
165
|
+ " -O {images,fonts,all,none}, --optimize-size {images,fonts,all,none}\n",
|
|
166
|
+ " Optimize output size for specified features.\n",
|
|
167
|
+ " -v, --verbose Show warnings and information messages.\n",
|
|
168
|
+ " -d, --debug Show debugging messages.\n",
|
|
169
|
+ " -q, --quiet Hide logging messages.\n"
|
|
170
|
+ ]
|
|
171
|
+ }
|
|
172
|
+ ],
|
|
173
|
+ "source": [
|
|
174
|
+ "! weasyprint --help"
|
|
175
|
+ ]
|
|
176
|
+ },
|
|
177
|
+ {
|
|
178
|
+ "cell_type": "code",
|
|
179
|
+ "execution_count": 20,
|
|
180
|
+ "metadata": {},
|
|
181
|
+ "outputs": [],
|
|
182
|
+ "source": [
|
|
183
|
+ "! weasyprint playcard.html playcard.pdf"
|
|
184
|
+ ]
|
|
185
|
+ },
|
|
186
|
+ {
|
|
187
|
+ "cell_type": "code",
|
|
188
|
+ "execution_count": 21,
|
|
189
|
+ "metadata": {},
|
|
190
|
+ "outputs": [],
|
|
191
|
+ "source": [
|
|
192
|
+ "! weasyprint -s playcard.css playcard.html playcard.pdf"
|
|
193
|
+ ]
|
|
194
|
+ },
|
|
195
|
+ {
|
|
196
|
+ "cell_type": "markdown",
|
|
197
|
+ "metadata": {},
|
|
198
|
+ "source": [
|
|
199
|
+ "## Weasyprint links\n",
|
|
200
|
+ "\n",
|
|
201
|
+ "https://doc.courtbouillon.org/weasyprint/stable/\n",
|
|
202
|
+ "\n",
|
|
203
|
+ "https://weasyprint.org/"
|
|
204
|
+ ]
|
|
205
|
+ },
|
|
206
|
+ {
|
|
207
|
+ "cell_type": "markdown",
|
|
208
|
+ "metadata": {},
|
|
209
|
+ "source": [
|
|
210
|
+ "## CSS links\n",
|
|
211
|
+ "\n",
|
|
212
|
+ "https://pzwiki.wdka.nl/mediadesign/Paged_Media_CSS_examples"
|
|
213
|
+ ]
|
|
214
|
+ },
|
|
215
|
+ {
|
|
216
|
+ "cell_type": "code",
|
|
217
|
+ "execution_count": null,
|
|
218
|
+ "metadata": {},
|
|
219
|
+ "outputs": [],
|
|
220
|
+ "source": []
|
|
221
|
+ }
|
|
222
|
+ ],
|
|
223
|
+ "metadata": {
|
|
224
|
+ "kernelspec": {
|
|
225
|
+ "display_name": "Python 3 (ipykernel)",
|
|
226
|
+ "language": "python",
|
|
227
|
+ "name": "python3"
|
|
228
|
+ },
|
|
229
|
+ "language_info": {
|
|
230
|
+ "codemirror_mode": {
|
|
231
|
+ "name": "ipython",
|
|
232
|
+ "version": 3
|
|
233
|
+ },
|
|
234
|
+ "file_extension": ".py",
|
|
235
|
+ "mimetype": "text/x-python",
|
|
236
|
+ "name": "python",
|
|
237
|
+ "nbconvert_exporter": "python",
|
|
238
|
+ "pygments_lexer": "ipython3",
|
|
239
|
+ "version": "3.7.3"
|
|
240
|
+ }
|
|
241
|
+ },
|
|
242
|
+ "nbformat": 4,
|
|
243
|
+ "nbformat_minor": 4
|
|
244
|
+}
|