def split_pdf(fp, pagenos=[]):
# Remove any possible duplicate pages
pagenos = list(set(pagenos))
# Create the pdf reader
inputpdf = PdfFileReader(fp)
# Create the pdf writer
output = PdfFileWriter()
# Loop through all the page numbers we want to split
for i in pagenos:
# Add each page to the writer
output.addPage(inputpdf.getPage(i))
return output
# Gets all top level sections from the PDF
评论列表
文章目录