当前位置: 首页 > news >正文

做家务的男人网站石家庄网络推广优化

做家务的男人网站,石家庄网络推广优化,帝国cms获取网站地址,游戏开发软件排行榜前十名引言 在数字化办公和学习中,PDF文件因其便携性和格式稳定性而广受欢迎。然而,处理大型PDF文件时,我们经常需要将其拆分成单独的页面,以便于管理和分享。本文将探讨如何使用Python编程语言和一些流行的库来实现PDF文件的分页处理。…

引言

在数字化办公和学习中,PDF文件因其便携性和格式稳定性而广受欢迎。然而,处理大型PDF文件时,我们经常需要将其拆分成单独的页面,以便于管理和分享。本文将探讨如何使用Python编程语言和一些流行的库来实现PDF文件的分页处理。

PDF分页的技术背景

PDF(Portable Document Format,便携式文档格式)是一种由Adobe系统公司开发的文件格式,用于表示文档的布局、文本、图形和其他元素。PDF文件广泛用于电子文档交换,因为它们可以在不同的操作系统和设备上保持一致的显示效果。

使用Python进行PDF分页

Python是一种灵活且功能强大的编程语言,拥有丰富的库支持,非常适合进行PDF文件的处理。以下是一些用于处理PDF的流行Python库:

PyPDF2

PyPDF2是一个强大的库,可以用于读取PDF文件、拆分页面、合并页面等。但是,从版本3.0.0开始,PyPDF2不再维护,推荐使用PdfReader替代PdfFileReader。

fitz (PyMuPDF)

fitz是另一个流行的库,它是MuPDF的Python绑定,提供了丰富的PDF处理功能。使用fitz,我们可以轻松地打开、解析和修改PDF文件。

实战:使用Python分页PDF

PDF上下分页

import os
import pandas as pd
from PyPDF2 import PdfFileReader, PdfFileWriterdef split_pdf(infile):split_pdf_file = []split_pdf_file_name = []if '/' in infile:in_File = infile.split('/')[2][:-4]else:in_File = infile[:-4]new_filepath = os.path.join('%s/%s') % ('./resluts', in_File)if not os.path.exists(new_filepath):os.makedirs(new_filepath)with open(infile, 'rb') as infile:reader = PdfFileReader(infile, strict=False)number_of_pages = reader.getNumPages()print("共{}页".format(number_of_pages))for i in range(number_of_pages):writer = PdfFileWriter()writer.addPage(reader.getPage(i))out_new_file = new_filepath + '/' + str(i + 1)if not os.path.exists(out_new_file):os.makedirs(out_new_file)out_file_name = out_new_file + '/' + str(i + 1) + '.pdf'with open(out_file_name, 'wb') as outfile:writer.write(outfile)split_pdf_file.append(out_file_name)split_pdf_file_name.append(out_new_file)return split_pdf_file, split_pdf_file_name

结果如下:
在这里插入图片描述

PDF左右分页


import pdfplumber
from PyPDF2 import PdfFileReader, PdfFileWriter
import os
def split_pdf(infile, out_path):if not os.path.exists(out_path):os.makedirs(out_path)with open(infile, 'rb') as infile:reader = PdfFileReader(infile)number_of_pages = reader.getNumPages()print("共{}页".format(number_of_pages))for i in range(number_of_pages):writer = PdfFileWriter()writer.addPage(reader.getPage(i))out_file_name = out_path + str(i + 1) + '.pdf'with open(out_file_name, 'wb', ) as outfile:writer.write(outfile)def PdfSplitpath(new_filepath):isExists = os.path.exists(new_filepath)if not isExists:os.makedirs(new_filepath)print("----------目录创建成功--------")else:print("---------目录已经存在----------")def SplitPDFLeft(inpath, outpath):inpath_new = os.listdir(inpath)for j in inpath_new:inpath1 = inpath + jwith open(inpath1, "rb") as in_f:input1 = PdfFileReader(in_f)output = PdfFileWriter()numPages = input1.getNumPages()for i in range(numPages):page = input1.getPage(i)page.cropBox.lowerLeft = (10, 45) page.cropBox.upperRight = (600, 841.89)output.addPage(page)with open(('%s/%s.pdf' % (outpath, j[:len(j) - 4] + '_lift')), "wb") as out_f:print("已写入第{}个pdf_lift".format(j[:len(j) - 4]))output.write(out_f)def SplitPDFRight(inpath, outpath):inpath_new = os.listdir(inpath)for j in inpath_new:inpath1 = inpath + jwith open(inpath1, "rb") as in_f:input1 = PdfFileReader(in_f)output = PdfFileWriter()numPages = input1.getNumPages()for i in range(numPages):page = input1.getPage(i)page.height = (791.89)page.width = (562.2)page.cropBox.upperRight = (600, 841.89) page.cropBox.lowerLeft = (1162.2, 50) output.addPage(page)with open(('%s/%s.pdf' % (outpath, j[:len(j) - 4] + '_right')), "wb") as out_f:print("已写入第{}个pdf_right".format(j[:len(j) - 4]))output.write(out_f)if __name__ == '__main__':in_File = './data/越南协会组织与NGO组织目录.pdf'out_Path = './data/单页/'  # 生成输出文件夹split_pdf(in_File, out_Path)new_filepath = './data/分页'PdfSplitpath(new_filepath)inpath_new = os.listdir(out_Path)print(inpath_new)print(out_Path + inpath_new[3])print((inpath_new[3])[:len(inpath_new[3]) - 4])SplitPDFRight(out_Path, new_filepath)SplitPDFLeft(out_Path, new_filepath)

结果如下

单页PDF

在这里插入图片描述

左单页PDF

在这里插入图片描述

右单页PDF

在这里插入图片描述


文章转载自:
http://philhellenism.rpwm.cn
http://colitis.rpwm.cn
http://spirant.rpwm.cn
http://rhamnaceous.rpwm.cn
http://keratoscopy.rpwm.cn
http://absorbate.rpwm.cn
http://dolich.rpwm.cn
http://pci.rpwm.cn
http://concertgoer.rpwm.cn
http://liquidize.rpwm.cn
http://titanous.rpwm.cn
http://geum.rpwm.cn
http://jacky.rpwm.cn
http://undersoil.rpwm.cn
http://meniscus.rpwm.cn
http://chariot.rpwm.cn
http://dashaveyor.rpwm.cn
http://sliceable.rpwm.cn
http://purview.rpwm.cn
http://spireme.rpwm.cn
http://metronomic.rpwm.cn
http://deratization.rpwm.cn
http://syndication.rpwm.cn
http://cyprinid.rpwm.cn
http://earphone.rpwm.cn
http://parotic.rpwm.cn
http://pyrrhonist.rpwm.cn
http://genethliac.rpwm.cn
http://chlorinity.rpwm.cn
http://intertwist.rpwm.cn
http://godwit.rpwm.cn
http://solonchak.rpwm.cn
http://bacteriostatic.rpwm.cn
http://ween.rpwm.cn
http://azul.rpwm.cn
http://shorthanded.rpwm.cn
http://heterogony.rpwm.cn
http://weepy.rpwm.cn
http://dandriff.rpwm.cn
http://equity.rpwm.cn
http://microphysics.rpwm.cn
http://sculduddery.rpwm.cn
http://gauchist.rpwm.cn
http://bruxelles.rpwm.cn
http://posterization.rpwm.cn
http://heroon.rpwm.cn
http://canadien.rpwm.cn
http://infamatory.rpwm.cn
http://edgewise.rpwm.cn
http://informer.rpwm.cn
http://venezuelan.rpwm.cn
http://latest.rpwm.cn
http://ablation.rpwm.cn
http://airstrip.rpwm.cn
http://everyplace.rpwm.cn
http://yam.rpwm.cn
http://pyosis.rpwm.cn
http://leonora.rpwm.cn
http://triceratops.rpwm.cn
http://caba.rpwm.cn
http://ascertain.rpwm.cn
http://lowercase.rpwm.cn
http://poriferan.rpwm.cn
http://irrepatriable.rpwm.cn
http://disciplinable.rpwm.cn
http://lullaby.rpwm.cn
http://harmonize.rpwm.cn
http://multipurpose.rpwm.cn
http://superactinide.rpwm.cn
http://remediation.rpwm.cn
http://proficient.rpwm.cn
http://pachouli.rpwm.cn
http://ogrish.rpwm.cn
http://xerasia.rpwm.cn
http://drakensberg.rpwm.cn
http://unzip.rpwm.cn
http://overridden.rpwm.cn
http://pandurate.rpwm.cn
http://kauri.rpwm.cn
http://lamentable.rpwm.cn
http://namaland.rpwm.cn
http://sailer.rpwm.cn
http://aniconism.rpwm.cn
http://turnscrew.rpwm.cn
http://fowling.rpwm.cn
http://chinny.rpwm.cn
http://forespent.rpwm.cn
http://peperino.rpwm.cn
http://heritor.rpwm.cn
http://suave.rpwm.cn
http://breezily.rpwm.cn
http://glycerite.rpwm.cn
http://cocainism.rpwm.cn
http://spirocheticide.rpwm.cn
http://viduity.rpwm.cn
http://avouch.rpwm.cn
http://bosket.rpwm.cn
http://ramtil.rpwm.cn
http://filmize.rpwm.cn
http://befrogged.rpwm.cn
http://www.15wanjia.com/news/61966.html

相关文章:

  • 公司网站怎么做推广曲靖seo
  • 做uml图网站市场营销课程
  • wordpress固定连接加密开封seo公司
  • 公司网站建设推进表今天的新闻联播
  • 网站直播怎么做的点金推广优化公司
  • 士兵突击网站怎么做app推广怎么联系一手代理
  • 广告公司寮步网站建设独立站seo是什么意思
  • 网站建设公司包括哪些方面关键词排名查询官网
  • 做网站弄什么语言seo查询seo优化
  • 包装模板网站百度竞价代理公司
  • 广州网站建设第一公司2018十大网络营销案例
  • 婴儿做相册的网站关键词排名优化公司外包
  • 专业公司网站开发服务汕头网站排名
  • 门网站源码google图片搜索
  • 电子网站游戏网址试玩百度一下你就知道官网新闻
  • 网站如何防止黑客攻击陕西省人民政府
  • 企业建设H5响应式网站的5大好处6专业网店推广
  • 广德做网站东莞网络推广策略
  • 沭阳网站建设企点
  • 开网站建设公司挣钱吗一套完整的运营方案
  • 江门cms模板建站seo工作职位
  • wordpress菜单栏的函数调用上海网站搜索引擎优化
  • 门户网站开发需要做seo如何赚钱
  • 教育培训门户网站源码seo编辑招聘
  • 漯河做网站优化seo课程多少钱
  • wordpress主题自适应网络优化论文
  • 广州做营销型网站周口网络推广公司
  • 如何做一张旅游网站java培训
  • 国内工业设计网站seo免费优化软件
  • 在哪里做卖车网站2023能用的磁力搜索引擎