#!/usr/bin/env python
# coding: utf-8
# [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/py-pdf/fpdf2/blob/master/tutorial/notebook.ipynb)
[![Open In nbviewer](https://img.shields.io/badge/Open_In-nbviewer-blue?logo=jupyter)](https://nbviewer.org/github/py-pdf/fpdf2/blob/master/tutorial/notebook.ipynb)
# # Hello World with fpdf2
# This [Jupyter notebook](https://jupyter.org/) demontrates some basic usage of the Python [fpdf2](https://github.com/py-pdf/fpdf2) library
# In[1]:
# Installation of fpdf2 with PIP:
get_ipython().system('pip install fpdf2')
# In[1]:
# Enable deprecation warnings:
import warnings
warnings.simplefilter('default', DeprecationWarning)
# In[1]:
# Generate a PDF:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('helvetica', size=48)
pdf.cell(text="hello world")
pdf_bytes = pdf.output()
# In[14]:
# Display the PDF in the notebook by embedding it as HTML content:
WIDTH, HEIGHT = 800, 400
from base64 import b64encode
from IPython.display import display, HTML
base64_pdf = b64encode(pdf_bytes).decode("utf-8")
display(HTML(f'