1.通过fitz
import fitz #读取文件 path = ‘xx.pdf‘ file_handle = fitz.open(path) #读取stream pdf_stream = b‘xxxxxx‘ file_handle = fitz.open(stream=pdf_stream, filetype=‘bytes‘) #保存为文件 output_file = ‘XX.pdf‘ file_handle.write(output_file) #保存为stream out_pdf_stream = file_handle.write()
原文:https://www.cnblogs.com/GoonerWHM/p/14167096.html