{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from weasyprint import HTML, CSS\n",
    "from weasyprint.fonts import FontConfiguration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "html = HTML(url=\"https://federicoponi.it\")\n",
    "font_config = FontConfiguration()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "css = CSS(string='''\n",
    "@page{\n",
    "        size: A4;\n",
    "        margin: 15mm;\n",
    "        background-color: white;\n",
    "        font-family: monospace;\n",
    "        font-size: 8pt;\n",
    "        color: black;\n",
    "            \n",
    "        img{\n",
    "        display:none;}\n",
    "    }\n",
    "    \n",
    "    body{\n",
    "        font-family: serif;\n",
    "        font-size: 12pt;\n",
    "        line-height: 1.4;\n",
    "        color: black;\n",
    "    }\n",
    "    \n",
    "    h1{\n",
    "        width: 100%;\n",
    "        text-align: center;\n",
    "        font-size: 250%;\n",
    "        line-height: 1.25;\n",
    "        color: orange;\n",
    "    }\n",
    "    \n",
    "    img{\n",
    "        display:none;\n",
    "    }\n",
    "    \n",
    "    #maxed responsive-img{\n",
    "    display:none;\n",
    "    }\n",
    "    \n",
    "    #submeta {\n",
    "    display:none;\n",
    "    }\n",
    "\n",
    "''', font_config=font_config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "html.write_pdf('mydocument.pdf', stylesheets=[css])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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
}
