-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplitPdf.py
31 lines (23 loc) · 896 Bytes
/
SplitPdf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from dynamicpdf_api.pdf import Pdf
from dynamicpdf_api.pdf_resource import PdfResource
from Shared import *
def split_pdf(apikey, full_path):
pdf=Pdf()
pdf.api_key=apikey
split(pdf, full_path, 1, 3, "splitpdf-one.pdf")
split(pdf, full_path, 6, 2, "splitpdf-two.pdf")
response = pdf.process()
def split(pdf, full_path, startPage, pageCount, outputFile):
inputA = pdf.add_pdf(PdfResource(full_path + "pdfnumberedinput.pdf"))
inputA.start_page = startPage
inputA.page_count = pageCount
response = pdf.process()
if response.is_successful:
with open(output_path + outputFile, "wb") as output_file:
output_file.write(response.content)
else:
print(response.error_id)
print(response.error_message)
print(response.error_json)
if __name__ == "__main__":
split_pdf(api_key, base_path + "/split-pdf/")