網際內容管理 40823129

  • Home
    • Site Map
    • reveal
    • blog
  • 每週內容
    • W1~W5
    • W6
    • W7
    • W8
    • W9~W10
    • W11~W13
    • W14
    • W15
    • W16~W17
  • ssh key  設定
  • putty  設定
  • 利用@gm帳號建立blogger
  • Cmsimde建立網誌
  • Pelican建立Blog
W14 << Previous Next >> W16~W17

W15

利用Pypdf2切割pdf檔

切割PDF之.py程式檔

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# pypdf2_ex1.py
import os
from PyPDF2 import PdfFileWriter, PdfFileReader
    
pdfReader = PdfFileReader(open("2002_Book_Real-WorldASPNETBuildingAConte.pdf", "rb"))
information = [("WhatIsCMS",18,45)]
    
for page in range(len(information)):
    pdf_writer = PdfFileWriter()
    start = information[page][1]
    end = information[page][2]
    while start<=end:
        pdf_writer.addPage(pdfReader.getPage(start-1))
        start+=1
    if not os.path.exists("./"):
        os.makedirs(savepath)
    output_filename = '{}_{}_page_{}.pdf'.format(information[page][0],information[page][1], information[page][2])
    with open(output_filename,'wb') as out:
        pdf_writer.write(out)

W14 << Previous Next >> W16~W17

Copyright © All rights reserved | This template is made with by Colorlib