python設置pdf(大熊的遇到的坑)


導出:選用pdfkit

參考官方鏈接:https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

1.大小

設置導出的大小可以用page-size也可以直接page-wight,page-height:

Page sizes:
  The default page size of the rendered document is A4, but using this
  --page-size optionthis can be changed to almost anything else, such as: A3,
  Letter and Legal.  For a full list of supported pages sizes please see
  <http://qt-project.org/doc/qt-4.8/qprinter.html#PaperSize-enum>.

  For a more fine grained control over the page size the --page-height and
  --page-width options may be used

 

加密:選用pypdf2,但是pypdf2中所有者和用戶密碼都給permit所有權限,想設置更高級的安全都不行

去pypdf2的pdf.py源碼中找到如下代碼

   # permit everything:
        P = -1
        O = ByteStringObject(_alg33(owner_pwd, user_pwd, rev, keylen))
        ID_1 = ByteStringObject(md5(b_(repr(time.time()))).digest())
        ID_2 = ByteStringObject(md5(b_(repr(random.random()))).digest())
        self._ID = ArrayObject((ID_1, ID_2))
        if rev == 2:

權限p=-1(all,-3904表示除了閱讀外,關閉其他所有權限

這樣打印、復制的權限就會被所有者關閉

 

元數據

作者、關鍵字等,pypdf2中用pdfwriter這樣做即可

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM