def test_split():
i = ILovePdf(config.PUBLIC_KEY, config.SECRET_KEY)
i.new_task("split")
i.add_file("test.pdf")
i.execute(ranges="1-2,5-8")
i.download()
zip_ref = zipfile.ZipFile("out.zip", "r")
zip_ref.extractall("test_split")
zip_ref.close()
assert len(glob.glob("test_split/*.pdf")) == 2
output_file1 = PdfFileReader(open("test_split/test-1-2.pdf", "rb"))
output_file2 = PdfFileReader(open("test_split/test-5-8.pdf", "rb"))
assert output_file1.getNumPages() == 2
assert output_file2.getNumPages() == 4
os.remove("out.zip")
shutil.rmtree("test_split")
评论列表
文章目录