cool hit counter Use Python to elegantly convert PDF to picture_Intefrankly

Use Python to elegantly convert PDF to picture

Author: qikqiak

source (of information etc):

I've collected a lot of good documents before, but it's not very convenient when you need to look at them, you need to find the file, and if you're on mobile you often need to download the relevant plug-ins to do so, and the biggest problem is that it's not easy to organize and share the information. Wouldn't it solve these problems if we could convert the xp to a web page? It can also be shared out directly.

The package is used here to process the file, and for the sake of convenience and speed, I'm converting a page directly into an image here, so I don't need to identify every element in the page, which is not necessary.


The core code is simple, that is, the file is read out, converted to , and then you can get the binary data of each page according to the API, get the binary data over, it is easy to image processing, here with the package to image processing.

It should be noted that the general PDF file is larger, if a one-time conversion of the entire PDF file needs to be careful of the problem of memory overflow, we will be the first time the entire PDF file loaded into memory to avoid reloading each time you read.

batch processing

The above has completed the conversion of a page, to complete the conversion of the entire file is very simple, just need to get the total page number of the file, and then loop through it. Considering that the conversion is time consuming, you can use asynchronous processing to speed it up. For example, you can use to with processing, making sure to watch out for memory leaks.

The core code has been put together on github, well, when there is time to prepare to do a public conversion of the service, open to the public use.

Took some time and made it into a standalone service: Feel free to try it out!

Title image: pexels, licensed by CC0.

1、Python Batch Merge Excel Files with Merged Cells
2、KaliLinux Web Penetration Testing Manual 2nd Edition 26 Using the browsers own development tools to do basic analysis and modification
3、Watching Qin Shi Ming Yue caused a crawl
4、Versioning with svn on top of IntelliJIDEA
5、Deal blocked Try these options

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送