# First convert the notebook into a HTML page nb_path=$1 empty_string="" nb_path_without_ext=$(echo "$nb_path" | sed "s/.ipynb/$empty_string/") jupyter nbconvert --to html $nb_path # Then convert the HTML into a PDF with Weasyprint weasyprint -s notebook-to-pdf.css $nb_path_without_ext.html $nb_path_without_ext.pdf # Then convert the PDF into a booklet PDF pdfbook2 $nb_path_without_ext.pdf --no-crop --paper a4paper