How to detect a rotated page in a PDF document in Python?

核能气质少年 提交于 2020-08-05 04:17:21

问题


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.


回答1:


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

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

it can be 0, 90, 180, 270 or None



来源:https://stackoverflow.com/questions/34515674/how-to-detect-a-rotated-page-in-a-pdf-document-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!