如何在Python中检测PDF文档中的旋转页面? [英] How to detect a rotated page in a PDF document in Python?

查看:432
本文介绍了如何在Python中检测PDF文档中的旋转页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出具有多个页面的PDF文档,如何检查给定页面是否旋转(-90、90或180º)?最好使用Python(pdfminer,pyPDF)...

Given a PDF document with multiple pages, how to check if a given page is rotated (-90, 90 or 180º)? Preferable using Python (pdfminer, pyPDF) ...

更新:扫描页面,并且大部分页面由文本组成.

UPDATE: The pages are scanned, and most of the page is composed by text.

推荐答案

我只是在PyPDF2中使用了页面的/Rotate属性:

I used simply /Rotate attribute of the page in PyPDF2:

 pdf = PyPDF2.PdfFileReader(open('example.pdf', 'rb'))
 orientation = pdf.getPage(pagenumber).get('/Rotate')

它可以是090180270None

这篇关于如何在Python中检测PDF文档中的旋转页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆