#!/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'')) # In[1]: # Diplay a download button: display(HTML(f'Click to download PDF')) # To continue learning about `fpdf2`, check our tutorial: # - [English](https://py-pdf.github.io/fpdf2/Tutorial.html) # - [Deutsch](https://py-pdf.github.io/fpdf2/Tutorial-de.html) # - [español](https://py-pdf.github.io/fpdf2/Tutorial-es.html) # - [हिंदी](https://py-pdf.github.io/fpdf2/Tutorial-हिंदी.html) # - [português](https://py-pdf.github.io/fpdf2/Tutorial-pt.html) # - [Русский](https://py-pdf.github.io/fpdf2/Tutorial-ru.html) # - [Italian](https://py-pdf.github.io/fpdf2/Tutorial-it.html) # - [français](https://py-pdf.github.io/fpdf2/Tutorial-fr.html) # - [Ελληνικά](https://py-pdf.github.io/fpdf2/Tutorial-gr.html) # - [עברית](https://py-pdf.github.io/fpdf2/Tutorial-he.html) # - [Dutch](https://py-pdf.github.io/fpdf2/Tutorial-nl.html)