Checks if PDF has the correct number of pages. If it has too many, warns
    the user. If it has too few, adds blank pages until the right length is
    reached.

def pad_pdf_pages(pdf_name, pages_per_q) -> None:
    """
    Checks if PDF has the correct number of pages. If it has too many, warns
    the user. If it has too few, adds blank pages until the right length is
    reached.
    """
    pdf = PyPDF2.PdfFileReader(pdf_name)
    output = PyPDF2.PdfFileWriter()
    num_pages = pdf.getNumPages()
    if num_pages > pages_per_q:
        logging.warning('{} has {} pages. Only the first '
                        '{} pages will get output.'
                        .format(pdf_name, num_pages, pages_per_q))

    # Copy over up to pages_per_q pages
    for page in range(min(num_pages, pages_per_q)):
        output.addPage(pdf.getPage(page))

    # Pad if necessary
    if num_pages < pages_per_q:
        for page in range(pages_per_q - num_pages):
            output.addBlankPage()

    # Output the PDF
    with open(pdf_name, 'wb') as out_file:
        output.write(out_file)