In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to divide the pdf file into pictures in python? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Use python to convert pdf into pictures
Recently, work needs to send an electronic version of word documents to others in order to protect copyright and prevent document content from being copied. Therefore, I searched a lot of tutorials and came up with the following ideas:
Online tutorials use word to add watermarks, and then select pdf format documents when saving, but I found that the generated pdf documents can still be copied. It means that there is no risk of preventing the leakage of data and the content being copied.
So, I think of first using word plus company watermark, and save the document as pdf format, and then use the advanced version of Foxit pdf Reader [official account background message request] to split pdf into pictures, and then use Foxit Reader to merge these pictures to generate new pdf documents. Since the document is merged from a picture, it will not be copied.
In fact, in addition to split and merge with pdf Reader, photoshop also has similar features, pdf into ps software, each page in the form of a picture page to save, and then use ps to export the picture to the pdf format of the document, this process is also possible, but when the number of pages of the document is more troublesome, this method takes time.
Finally, I decided to use python to solve this problem by splitting the pdf into pictures and then merging the pictures into pdf documents.
Today, let's record how to split pdf into pictures.
The following preparation libraries and packages are required to convert pdf to images:
Pdf2image
Compressed package proppler
First, install the pdf2image library, open the command line and enter the following:
Pip install pdf2image
Secondly, proppler is a prerequisite for the use of the pdf2image library, we need to download the proppler file, download address: http://blog.alivate.com.au/poppler-windows/, copy this URL to the computer side to open, find the Download download line, download the corresponding version according to the computer operating system, my computer window10 system, the version selected the latest version of poppler-0.68.0_x86, after the file is installed, extract to any disk I C disk to create a new file, and then extract to the new file, other disks have not been tested, should be fine. Then find the bin folder in the unzipped file, and copy the file path of the bin file (open the bin folder, as follows, click the path marked by the arrow with the left mouse button, and select the path to copy.
Open the system environment variable
Create a new environment variable as follows:
Then paste the path to the bin folder you just copied
Then press OK all the time, and the user environment variable above does the same, adding the path to the user environment variable. (specific operation steps to add environment variables, search the Internet by yourself).
The preparation work is done. The following is the execution of the code. If the code runs successfully, the pdf is divided into pictures.
Import pdf2image
Import os
Images = pdf2image.convert_from_path ("plan.pdf")
I = 0
If not os.path.exists (r "D:\ CS\ Learning Notes\ Mini function\ pdf to Pictures\ image"): # check whether the folder exists
Os.mkdir (r "D:\ CS\ Learning Notes\ Mini function\ pdf to Pictures\ image") # create a folder if it doesn't exist, where the file name is image
For image in images:
I + = 1
Image.save ("D:\ CS\ Learning Notes\ Mini function\ pdf transfer Picture\ image\\" + str (I) + ".jpg", "JPEG")
This is the answer to the question about how to divide the pdf file into pictures in python. I hope the above content can be of some help to everyone. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.