40823108 wcm2020

  • Home
    • Site Map
    • reveal
    • blog
  • 簡介
  • Grouping
    • 1a
  • 每周進度
    • W10-W11
    • W12-W15
    • W16-W17
  • Python程式
  • Cmsimde建立網誌方法
  • SSH教學
    • SSH Key產生
    • SSH Putty設定
  • Pelican建立Blog
  • @gm帳號建立blogger
  • VirtualBOX虛擬主機
  • scite編譯器
  • 期末報告
W10-W11 << Previous Next >> W16-W17

W12-W15

W12

在Windows10中安裝Ubuntu 20.04虛擬主機

W13

安裝Oracle VM VirtualBox建立虛擬主機

W14

編譯NGINX在虛擬與實體主機上完成網際 PDF 檔案管理系統.

W15

利用HxD編修pip.exe

將Pythonw.exe修改為Python.exe

利用Pypdf2切割PDF檔案

Pypdf2 examples:

# 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)
# pypdf2_ex2.py
import os
from PyPDF2 import PdfFileWriter, PdfFileReader
 
pdfReader = PdfFileReader(open("Beginning-Git-and-GitHub.pdf", "rb"))
information = [("GitAndGithub",17,105),("GitAndGithub",107,194),("GitAndGithub",196,289)]
 
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)
# pypdf2_ex3.py
# merge several pdf files
import sys
import PyPDF2
 
pdf_write_object = PyPDF2.PdfFileWriter()
 
#for i in sys.argv[1:]:
for i in ["WhatIsCMS.pdf","InforLifeCycle.pdf","EnterpriseContentManage.pdf"]:
    pdf_read_object = PyPDF2.PdfFileReader(i)
    print('processing file : '+ i + 'number of pages : ' +  str(pdf_read_object.numPages))
    for page in range(pdf_read_object.numPages):
        pdf_write_object.addPage(pdf_read_object.getPage(page))
 
final_file_object = open('2020CMS.pdf', 'wb')
pdf_write_object.write(final_file_object)
final_file_object.close()

選取要切割的PDF檔案

切割完成的PDF檔案


W10-W11 << Previous Next >> W16-W17

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