用pyPdf打开pdf网址

用pyPdf打开pdf网址,第1张

用pyPdf打开pdf网址

我认为urllib2将为您提供所需的东西

from urllib2 import Request, urlopenfrom pyPdf import PdfFileWriter, PdfFileReaderfrom StringIO import StringIOurl = "http://www.silicontao.com/ProgrammingGuide/other/beejnet.pdf"writer = PdfFileWriter()remoteFile = urlopen(Request(url)).read()memoryFile = StringIO(remoteFile)pdfFile = PdfFileReader(memoryFile)for pageNum in xrange(pdfFile.getNumPages()):        currentPage = pdfFile.getPage(pageNum)        #currentPage.mergePage(watermark.getPage(0))        writer.addPage(currentPage)outputStream = open("output.pdf","wb")writer.write(outputStream)outputStream.close()


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5644941.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存