{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Collective playcard generating time!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Git cheatsheet\n", "\n", "`git pull`\n", "\n", "`git status`\n", "\n", "`git log`\n", "\n", "`git add filename.txt`\n", "\n", "`git commit -m \"my short summary of what has changed\"`\n", "\n", "`git push`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate playcard.pdf with Weasyprint" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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", "\n", "`$ sudo pip3 install weasyprint==52.5`\n", "\n", "You can use Weasyprint as a Python library or from the command line." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Weasyprint as Python library" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "ename": "AttributeError", "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", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m/tmp/ipykernel_22626/3089759157.py\u001b[0m in \u001b[0;36m\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", "\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", "\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", "\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", "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/weasyprint/document.py\u001b[0m in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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", "\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" ] } ], "source": [ "from weasyprint import HTML, CSS\n", "\n", "HTML(filename='playcard.html').write_pdf('playcard.pdf', stylesheets=[CSS(filename='playcard.css')])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Weasyprint from the command line" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "usage: weasyprint [-h] [--version] [-i] [-e ENCODING] [-s STYLESHEET]\n", " [-m MEDIA_TYPE] [-u BASE_URL] [-a ATTACHMENT] [-p]\n", " [-O {images,fonts,all,none}] [-v] [-d] [-q]\n", " input output\n", "\n", "Renders web pages to PDF.\n", "\n", "positional arguments:\n", " input URL or filename of the HTML input, or - for stdin\n", " output Filename where output is written, or - for stdout\n", "\n", "optional arguments:\n", " -h, --help show this help message and exit\n", " --version Print WeasyPrint's version number and exit.\n", " -i, --info Print system information and exit.\n", " -e ENCODING, --encoding ENCODING\n", " Character encoding of the input\n", " -s STYLESHEET, --stylesheet STYLESHEET\n", " URL or filename for a user CSS stylesheet. May be\n", " given multiple times.\n", " -m MEDIA_TYPE, --media-type MEDIA_TYPE\n", " Media type to use for @media, defaults to print\n", " -u BASE_URL, --base-url BASE_URL\n", " Base for relative URLs in the HTML input. Defaults to\n", " the input's own filename or URL or the current\n", " directory for stdin.\n", " -a ATTACHMENT, --attachment ATTACHMENT\n", " URL or filename of a file to attach to the PDF\n", " document\n", " -p, --presentational-hints\n", " Follow HTML presentational hints.\n", " -O {images,fonts,all,none}, --optimize-size {images,fonts,all,none}\n", " Optimize output size for specified features.\n", " -v, --verbose Show warnings and information messages.\n", " -d, --debug Show debugging messages.\n", " -q, --quiet Hide logging messages.\n" ] } ], "source": [ "! weasyprint --help" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "! weasyprint playcard.html playcard.pdf" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "! weasyprint -s playcard.css playcard.html playcard.pdf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Weasyprint links\n", "\n", "https://doc.courtbouillon.org/weasyprint/stable/\n", "\n", "https://weasyprint.org/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CSS links\n", "\n", "https://pzwiki.wdka.nl/mediadesign/Paged_Media_CSS_examples" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 4 }