• <small id='KlcGg'></small><noframes id='KlcGg'>

    <legend id='KlcGg'><style id='KlcGg'><dir id='KlcGg'><q id='KlcGg'></q></dir></style></legend>

          <bdo id='KlcGg'></bdo><ul id='KlcGg'></ul>
        <i id='KlcGg'><tr id='KlcGg'><dt id='KlcGg'><q id='KlcGg'><span id='KlcGg'><b id='KlcGg'><form id='KlcGg'><ins id='KlcGg'></ins><ul id='KlcGg'></ul><sub id='KlcGg'></sub></form><legend id='KlcGg'></legend><bdo id='KlcGg'><pre id='KlcGg'><center id='KlcGg'></center></pre></bdo></b><th id='KlcGg'></th></span></q></dt></tr></i><div id='KlcGg'><tfoot id='KlcGg'></tfoot><dl id='KlcGg'><fieldset id='KlcGg'></fieldset></dl></div>

        <tfoot id='KlcGg'></tfoot>

        在python中打开一个受保护的pdf文件

        Open a protected pdf file in python(在python中打开一个受保护的pdf文件)

                • <bdo id='I0J7K'></bdo><ul id='I0J7K'></ul>
                  <tfoot id='I0J7K'></tfoot>
                  <legend id='I0J7K'><style id='I0J7K'><dir id='I0J7K'><q id='I0J7K'></q></dir></style></legend>
                • <small id='I0J7K'></small><noframes id='I0J7K'>

                  <i id='I0J7K'><tr id='I0J7K'><dt id='I0J7K'><q id='I0J7K'><span id='I0J7K'><b id='I0J7K'><form id='I0J7K'><ins id='I0J7K'></ins><ul id='I0J7K'></ul><sub id='I0J7K'></sub></form><legend id='I0J7K'></legend><bdo id='I0J7K'><pre id='I0J7K'><center id='I0J7K'></center></pre></bdo></b><th id='I0J7K'></th></span></q></dt></tr></i><div id='I0J7K'><tfoot id='I0J7K'></tfoot><dl id='I0J7K'><fieldset id='I0J7K'></fieldset></dl></div>
                    <tbody id='I0J7K'></tbody>
                  本文介绍了在python中打开一个受保护的pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我写了一个pdf破解,找到了被保护的pdf文件的密码.我想用 Python 编写一个程序,可以在没有密码的情况下在屏幕上显示该 pdf 文件.我使用 PyPDF 库.我知道如何在没有密码的情况下打开文件,但不知道受保护的文件.知道吗?谢谢

                  I write a pdf cracking and found the password of the protected pdf file. I want to write a program in Python that can display that pdf file on the screen without password.I use the PyPDF library. I know how to open a file without the password, but can't figure out the protected one.Any idea? Thanks

                  filePath = raw_input()
                  password = 'abc'
                  if sys.platform.startswith('linux'):
                         subprocess.call(["xdg-open", filePath])
                  

                  推荐答案

                  KL84给出的方法基本可以,但是代码不正确(每页都写输出文件).清理后的版本在这里:

                  The approach shown by KL84 basically works, but the code is not correct (it writes the output file for each page). A cleaned up version is here:

                  https://gist.github.com/bzamecnik/1abb64affb21322256f1c4ebbb59a364

                  # Decrypt password-protected PDF in Python.
                  # 
                  # Requirements:
                  # pip install PyPDF2
                  
                  from PyPDF2 import PdfFileReader, PdfFileWriter
                  
                  def decrypt_pdf(input_path, output_path, password):
                    with open(input_path, 'rb') as input_file, 
                      open(output_path, 'wb') as output_file:
                      reader = PdfFileReader(input_file)
                      reader.decrypt(password)
                  
                      writer = PdfFileWriter()
                  
                      for i in range(reader.getNumPages()):
                        writer.addPage(reader.getPage(i))
                  
                      writer.write(output_file)
                  
                  if __name__ == '__main__':
                    # example usage:
                    decrypt_pdf('encrypted.pdf', 'decrypted.pdf', 'secret_password')
                  

                  这篇关于在python中打开一个受保护的pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                  <i id='cPX0u'><tr id='cPX0u'><dt id='cPX0u'><q id='cPX0u'><span id='cPX0u'><b id='cPX0u'><form id='cPX0u'><ins id='cPX0u'></ins><ul id='cPX0u'></ul><sub id='cPX0u'></sub></form><legend id='cPX0u'></legend><bdo id='cPX0u'><pre id='cPX0u'><center id='cPX0u'></center></pre></bdo></b><th id='cPX0u'></th></span></q></dt></tr></i><div id='cPX0u'><tfoot id='cPX0u'></tfoot><dl id='cPX0u'><fieldset id='cPX0u'></fieldset></dl></div>
                  <legend id='cPX0u'><style id='cPX0u'><dir id='cPX0u'><q id='cPX0u'></q></dir></style></legend><tfoot id='cPX0u'></tfoot>

                  <small id='cPX0u'></small><noframes id='cPX0u'>

                      • <bdo id='cPX0u'></bdo><ul id='cPX0u'></ul>
                          <tbody id='cPX0u'></tbody>