如何在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')
它可以是0
,90
,180
,270
或None