updating the ASCII and reportlab canvas notebooks + reportlab cheatsheet, clearing all outputs

master
manetta 4 years ago
parent fa7d27fbd3
commit a47c04dfc5

@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 81,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 87,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -35,81 +35,11 @@
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n"
]
}
],
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Simple fill-up of a page, to set the reach of our canvas\n",
"lines = [] # All the lines will be stored here\n",
@ -129,7 +59,7 @@
},
"outputs": [],
"source": [
"# Another variation\n",
"# Another way to fill-up the page\n",
"import random \n",
"\n",
"lines = []\n",
@ -149,14 +79,17 @@
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# Same variation, but with multiple pages\n",
"# Same as above + a \"switch\" to make multipaged PDFs\n",
"import random \n",
"\n",
"multipage = True\n",
"number_of_pages = 100\n",
"\n",
"lines = []\n",
"pages = []\n",
@ -164,7 +97,7 @@
"txt = open('txt/language.txt', 'r').read()\n",
"words = txt.split()\n",
"\n",
"for page in range(100):\n",
"for page in range(number_of_pages):\n",
" \n",
" for linenumber in range(height):\n",
" word = random.choice(words)\n",
@ -176,7 +109,10 @@
" # Add a page\n",
" pages.append(lines)\n",
" lines = []\n",
" "
"\n",
"for page in pages:\n",
" print('\\n'.join(page))\n",
" print('-' * width)"
]
},
{
@ -209,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": 91,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -220,7 +156,7 @@
"pagewidth = 210*mm\n",
"pageheight = 297*mm\n",
"\n",
"c = Canvas(\"pdf/ASCII-canvas-to-PDF.pdf\", pagesize=(pagewidth, pageheight), bottomup=0)\n",
"c = Canvas(\"ASCII-canvas-to-PDF.pdf\", pagesize=(pagewidth, pageheight), bottomup=0)\n",
"c.setFont('Courier', 12)\n",
"\n",
"start_y = 10*mm # start position of the lines\n",
@ -242,13 +178,6 @@
" \n",
"c.save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {

@ -1,29 +1,45 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Reportlab Canvas (A4) - Bag of Words"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An example notebook to make PDFs with Reportlab. \n",
"\n",
"This notebook draws 100 words on an A4 PDF."
]
},
{
"cell_type": "code",
"execution_count": 266,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from reportlab.pdfgen.canvas import Canvas\n",
"from reportlab.lib.pagesizes import A4\n",
"from reportlab.lib.units import mm\n",
"from reportlab.lib.colors import pink, magenta, red, blue, yellow, lightyellow"
"from reportlab.lib.colors import magenta, lightgrey"
]
},
{
"cell_type": "code",
"execution_count": 277,
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"c = Canvas(\"pdf/reportlab-canvas-A4-bag-of-words.pdf\", pagesize=(210*mm, 297*mm), bottomup=0)"
"c = Canvas(\"reportlab-canvas-A4-bag-of-words.pdf\", pagesize=(210*mm, 297*mm), bottomup=0)"
]
},
{
"cell_type": "code",
"execution_count": 268,
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
@ -32,31 +48,18 @@
},
{
"cell_type": "code",
"execution_count": 269,
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"# Draw a background color\n",
"c.setFillColor(lightyellow)\n",
"c.setFillColor(lightgrey)\n",
"c.rect(0, 0, A4[0], A4[1], stroke=0, fill=1)"
]
},
{
"cell_type": "code",
"execution_count": 270,
"metadata": {},
"outputs": [],
"source": [
"# Draw a bag-of-words on the canvas, on random positions\n",
"import random\n",
"\n",
"txt = open('txt/language.txt', 'r').read()\n",
"words = txt.split()"
]
},
{
"cell_type": "code",
"execution_count": 271,
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
@ -73,124 +76,166 @@
},
{
"cell_type": "code",
"execution_count": 275,
"metadata": {},
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"# First bag-of-words: 100 randomly picked and positioned words, based on the text *Language and Software Studies* (`txt/language.txt`).\n",
"# Use the random module and open the language.txt file \n",
"import random\n",
"\n",
"txt = open('txt/language.txt', 'r').read()\n",
"words = txt.split()\n",
"\n",
"# Draw a random bag-of-words on the canvas\n",
"for n in range(100):\n",
" x = random.randint(0, 190)\n",
" y = random.randint(0, 280)\n",
" word = random.choice(words).strip(',.')\n",
" print(x, y, word)\n",
" c.drawString(x*mm, y*mm, word)\n",
"\n",
"# Add a small caption\n",
"c.setFont('Courier', 10)\n",
"c.setFillColor(blue)\n",
"c.drawCentredString(105*mm, 290*mm, 'Random words from Language and Software Studies, by Florian Cramer (2005)')\n",
"\n",
"# Save the PDF!\n",
"c.save()"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"37 107 a\n",
"24 100 formal\n",
"126 264 a\n",
"58 279 controls\n",
"41 250 an\n",
"36 142 program\n",
"111 153 programming\n",
"32 228 be\n",
"71 166 Originally\n",
"154 267 operations)\n",
"97 60 are\n",
"187 158 the\n",
"98 205 an\n",
"169 229 “code”\n",
"175 144 analog\n",
"166 9 yet\n",
"82 182 the\n",
"136 34 a\n",
"35 268 7\n",
"13 21 of\n",
"152 254 of\n",
"81 157 call\n",
"160 104 tomorrow\n",
"141 47 promises\n",
"140 220 of\n",
"155 201 The\n",
"62 59 terms.”\n",
"41 246 difficult\n",
"61 139 of\n",
"154 279 in\n",
"48 279 coded\n",
"59 88 artists\n",
"146 186 eventual\n",
"90 26 virus\n",
"102 261 act\n",
"55 265 computer\n",
"83 40 reflect\n",
"126 144 experiments\n",
"99 30 computation\n",
"5 221 concrete\n",
"96 129 occurs\n",
"19 89 computes\n",
"181 34 their\n",
"9 57 is\n",
"157 68 “performative”\n",
"19 95 computer\n",
"30 44 in\n",
"88 114 instructions\n",
"65 188 computer\n",
"81 149 German\n",
"70 207 whatever\n",
"113 31 representation\n",
"166 82 and\n",
"15 55 to\n",
"57 163 and\n",
"118 196 is\n",
"51 223 as\n",
"67 46 a\n",
"38 278 handle\n",
"136 134 Yet\n",
"35 170 poetry\n",
"146 111 “Interface”)\n",
"158 132 suitable\n",
"187 189 example\n",
"159 200 would\n",
"33 241 that\n",
"178 213 nothing\n",
"62 78 critically\n",
"166 205 of\n",
"169 42 more\n",
"122 154 itself\n",
"187 278 formal\n",
"85 59 ”Chapter\n",
"35 104 themselves\n",
"145 64 states\n",
"37 85 or\n",
"81 226 that\n",
"19 253 \n",
"157 55 string\n",
"187 125 semantic\n",
"142 224 transformation\n",
"115 3 the\n",
"98 46 Wesley\n",
"61 202 a\n",
"178 32 in\n",
"110 211 command\n",
"169 240 be\n",
"166 82 symbols\n",
"34 192 languages\n",
"30 68 is\n",
"46 172 that\n",
"3 276 “natural\n",
"123 242 computer\n",
"100 123 common\n",
"162 248 that\n",
"140 31 it\n",
"9 146 are\n",
"165 10 in\n",
"132 271 control\n",
"173 276 But\n"
"84 58 computing\n",
"173 112 programming\n",
"113 255 processing\n",
"102 115 programming\n",
"145 38 nothing\n",
"54 71 programming\n",
"106 139 programming\n",
"107 10 programming\n",
"49 84 programming\n",
"8 188 expressing\n",
"158 63 programming\n",
"124 257 anything\n",
"39 8 understanding\n",
"121 221 programming\n",
"91 127 programming\n",
"12 170 understanding\n",
"71 47 programming\n",
"17 33 nothing\n",
"36 280 programming\n",
"175 112 typing\n",
"173 275 thinking\n",
"69 217 involving\n",
"29 274 meaning\n",
"122 223 meaning\n",
"75 45 meaning\n",
"104 255 programming\n",
"94 172 Turing\n",
"48 181 programming\n",
"29 107 programming\n",
"72 179 speaking\n",
"185 238 programming\n",
"71 214 Nothing\n",
"25 279 programming\n",
"76 255 thinking\n",
"31 152 programming\n",
"26 237 denoting\n",
"161 56 storing\n",
"6 170 transmitting\n",
"70 38 “programming\n",
"5 112 indicating\n",
"156 188 giving\n",
"56 238 passing\n",
"142 37 accepting\n",
"109 92 trading\n",
"163 161 Writing\n",
"1 163 programming\n",
"157 1 phrasing\n",
"93 161 layering\n",
"61 170 nothing\n",
"62 162 processing\n",
"152 19 string\n",
"47 259 computing\n",
"63 69 reshaping\n",
"71 144 data—including\n",
"187 156 writing\n",
"156 227 consisting\n",
"125 119 meaning\n",
"68 45 writing\n",
"123 18 dragging\n",
"72 153 encoding\n",
"53 209 expressing\n",
"31 273 flying\n",
"17 32 programming\n",
"166 140 programming\n",
"167 117 programming\n",
"42 214 programming\n",
"144 271 encoding\n",
"131 255 understanding\n",
"133 2 programming\n",
"7 66 programming\n",
"124 206 involving\n",
"166 46 writing\n",
"158 135 thinking\n",
"104 237 understanding\n",
"18 206 amusing\n",
"11 97 according\n",
"9 169 Designing\n",
"28 199 According\n",
"152 205 writing\n",
"97 274 surprising\n",
"49 92 Reading\n"
]
}
],
"source": [
"# Draw on the canvas\n",
"for n in range(100):\n",
"# Another bag-of-words: word selections from Words of the Future\n",
"import os\n",
"import random\n",
"\n",
"bag = []\n",
"filenames = []\n",
"\n",
"folder = 'txt/words-for-the-future/'\n",
"for file in os.listdir(folder):\n",
" # print(folder+file)\n",
" txt = open('txt/language.txt', 'r').read()\n",
" words = txt.split()\n",
" bag += words\n",
" filenames.append(file) # We will use this for the caption\n",
"\n",
"# print(bag)\n",
"\n",
"# Select all the words that end on \"ing\" and draw them on the canvas\n",
"for word in words:\n",
" word = word.strip(',/\\\\!?;:\"\\'.') # \"clean up\" the words\n",
" x = random.randint(0, 190)\n",
" y = random.randint(0, 280)\n",
" word = random.choice(words).strip(',.')\n",
" print(x, y, word)\n",
" c.drawString(x*mm, y*mm, word)"
" if word.endswith('ing'):\n",
" print(x, y, word)\n",
" c.drawString(x*mm, y*mm, word)\n",
"\n",
"# Add a small caption\n",
"c.setFont('Courier', 10)\n",
"c.setFillColor(blue)\n",
"filenames_str = ', '.join(filenames)\n",
"c.drawCentredString(105*mm, 290*mm, 'Random words from: {f} (Words for the Future)'.format(f=filenames_str))\n",
"\n",
"# Save the PDF!\n",
"c.save()"
]
},
{
@ -221,50 +266,6 @@
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 273,
"metadata": {},
"outputs": [],
"source": [
"# Add a small caption\n",
"c.setFont('Courier', 10)\n",
"c.setFillColor(blue)\n",
"c.drawCentredString(105*mm, 285*mm, 'Random words from Language and Software Studies, by Florian Cramer (2005)')"
]
},
{
"cell_type": "code",
"execution_count": 274,
"metadata": {},
"outputs": [],
"source": [
"# Save the PDF!\n",
"#c.showPage()\n",
"c.save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save