Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

# merging pdf files

# merging pdf files
from PyPDF2 import PdfFileMerger

merger = PdfFileMerger()

input1 = open("document1.pdf", "rb")
input2 = open("document2.pdf", "rb")
input3 = open("document3.pdf", "rb")

# add the first 3 pages of input1 document to output
merger.append(fileobj = input1, pages = (0,3))

# insert the first page of input2 into the output beginning after the second page
merger.merge(position = 2, fileobj = input2, pages = (0,1))

# append entire input3 document to the end of the output document
merger.append(input3)

# Write to an output PDF document
output = open("document-output.pdf", "wb")
merger.write(output)
Comment

PREVIOUS NEXT
Code Example
Python :: plot histogram from counts and bin edges 
Python :: check for root python 
Python :: s.cookie.set python 
Python :: reverse range python 
Python :: semicolon python 
Python :: append to an array in 1st place python 
Python :: reading files in python 
Python :: for in print pyhton 
Python :: Python Iterating Through an Iterator 
Python :: df mask 
Python :: bitwise xor in python 
Python :: python cat 
Python :: time zone in python 
Python :: two underscores python 
Python :: Syntax of Opening a File in python 
Python :: np logical not 
Python :: how to take screenshot with python 
Python :: python console 
Python :: python with braces 
Python :: how to add a 2d array to one dataframe colum 
Python :: python dynamic variable name 
Python :: recursion in python 
Python :: how to add axis labels to a plotly barchart 
Python :: python qr scanner 
Python :: how add a favicon to django 
Python :: python delete key if exists 
Python :: sort a list python 
Python :: numpy.where 
Python :: += in python 
Python :: How to clone or copy a list in python 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =