def get_pages(pdf_filename, from_, to):
if to < from_:
to = from_
file = open(pdf_filename, 'rb')
pdf = PdfFileReader(file)
output = PdfFileWriter()
for i in range(from_ - 1, to):
output.addPage(pdf.getPage(i))
stream = BytesIO()
output.write(stream)
data = stream.getvalue()
file.close()
return data
评论列表
文章目录