from PyPDF2 import PdfWriter
writer = PdfWriter()
writer.add_blank_page(width=200, height=200)
data = b"any bytes - typically read from a file"
writer.add_attachment("smile.png", data)
with open("output.pdf", "wb") as output_stream:
writer.write(output_stream)