from pypdf import PdfReader, PdfWriter# rotate pdf filereader = PdfReader("dummy.pdf")page = reader.pages[0]page.rotate(270)writer = PdfWriterwriter.add_page(page)writer.write('tilt.pdf')# run python3 pdf_merger.py dummy.pdf twopage.pdf wtr.pdfimport sysfrom pypdf import PdfWriterinputs = sys.argv[1:]# merge pdf filesdef pdf_merger(pdf_list): merger = PdfWriter for pdf in pdf_list: merger.append(pdf) merger.write("merged-pdf.pdf") merger.closepdf_merger(inputs)from pypdf import PdfWriter, PdfReaderwatermark = PdfReader("wtr.pdf").pages[0]writer = PdfWriter(clone_from="twopage.pdf")for page in writer.pages: page.merge_page(watermark, over=False) # here set to False for watermarkingwriter.write("add_watermark.pdf")import sysfrom pypdf import PdfReader, PdfWriter# run python3 pdf_add_watermark.py # run python3 pdf_remove_watermark.py add_watermark.pdforiginal_pdf = sys.argv[1]with open(original_pdf, "rb") as input_file, open('remove_watermark.pdf', "wb") as output_file: reader = PdfReader(input_file) writer = PdfWriter for n in range(len(reader.pages)): page = reader.pages[n] del page["/Contents"][0] writer.add_page(page) writer.write(output_file)摘要:from pypdf import PdfReader, PdfWriter# rotate pdf filereader = PdfReader("dummy.pdf")page = reader.pages[0]page.rotate(270)writer
来源:自由坦荡的湖泊AI
免责声明:本站系转载,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本站联系,我们将在第一时间删除内容!