Merge PDF stored in Remote server using Python Last Updated : 16 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisites: Working with PDF files in Python There are many libraries for manipulating PDF files in Python but all are using when that all PDF files already downloaded in your local machine. But what if your target PDF files are in Remote server, you have only URLs of files and no required download in your machine or compute server. Here We will discuss this problem and solution for the same. Installation: Here we use the library of Python PyPDF2 for merging PDFs. pip install PyPDF2 We will merge the same pdf file twice. Link to the pdf file used is here Below is the implementation. Python3 1== from io import BytesIO, SEEK_SET, SEEK_END import PyPDF2 import requests # Create a class which convert PDF in # BytesIO form class ResponseStream(object): def __init__(self, request_iterator): self._bytes = BytesIO() self._iterator = request_iterator def _load_all(self): self._bytes.seek(0, SEEK_END) for chunk in self._iterator: self._bytes.write(chunk) def _load_until(self, goal_position): current_position = self._bytes.seek(0, SEEK_END) while current_position < goal_position: try: current_position = self._bytes.write(next(self._iterator)) except StopIteration: break def tell(self): return self._bytes.tell() def read(self, size = None): left_off_at = self._bytes.tell() if size is None: self._load_all() else: goal_position = left_off_at + size self._load_until(goal_position) self._bytes.seek(left_off_at) return self._bytes.read(size) def seek(self, position, whence = SEEK_SET): if whence == SEEK_END: self._load_all() else: self._bytes.seek(position, whence) # Merge PDFs using URL List url_list = ["lis of URL"] target_pdf_path = './Merged.pdf' pdf_writer = PyPDF2.PdfFileWriter() for url in url_list: response = requests.get(url) reader = PyPDF2.PdfFileReader(ResponseStream(response.iter_content(64))) for page in range(reader.getNumPages()): pdf_writer.addPage(reader.getPage(page)) # write to output file with open(target_pdf_path, 'wb') as g: pdf_writer.write(g) Output: The merged pdf file created is here Comment More infoAdvertise with us Next Article Setting up a simple HTTP server using Python P parth_ghinaiya Follow Improve Article Tags : Python python-utility Python-projects Practice Tags : python Similar Reads How To Send Files Using Python Built-In Http Server Python's built-in HTTP server offers a straightforward way to share files over a local network or the internet without the need for complex setups. In this tutorial, we'll walk through the step-by-step process of using Python's built-in HTTP server to send files to clients. Setting Up the HTTP Serve 2 min read GET and POST Requests Using Python This post discusses two HTTP (Hypertext Transfer Protocol) request methods  GET and POST requests in Python and their implementation in Python. What is HTTP? HTTP is a set of protocols designed to enable communication between clients and servers. It works as a request-response protocol between a cli 7 min read Retrieving File Data From HDFS using Python Snakebite Prerequisite: Hadoop Installation, HDFS Python Snakebite is a very popular Python library that we can use to communicate with the HDFS. Using the Python client library provided by the Snakebite package we can easily write Python code that works on HDFS. It uses protobuf messages to communicate direc 3 min read Setting up a simple HTTP server using Python In this article, we are going to learn how to set up a simple and local HTTP server using Python. An HTTP server can be very useful for testing Android, PC or Web apps locally during development. It can also be used to share files between two devices connected over the same LAN or WLAN network. Inst 2 min read Store Google Sheets data into SQLite Database using Python In this article, we are going to store google sheets data into a database using python. The first step is to enable the API and to create the credentials, so let's get stared. Enabling the APIs and creating the credentialsGo to Marketplace in Cloud Console.Click on ENABLE APIS AND SERVICESThen Searc 5 min read How to Execute Shell Commands in a Remote Machine using Python - Paramiko Paramiko is a Python library that makes a connection with a remote device through SSh. Paramiko is using SSH2 as a replacement for SSL to make a secure connection between two devices. It also supports the SFTP client and server model. Authenticating SSH connection To authenticate an SSH connection, 4 min read Like