zoukankan      html  css  js  c++  java
  • 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这样做即可

  • 相关阅读:
    join
    PS1-4
    tftp + bras
    awk调用shell
    curl
    ssh
    查看cp进度,使用watch
    tftp
    scp 链接文件的问题 + tar
    mysql必知必会(三、使用mysql)
  • 原文地址:https://www.cnblogs.com/daysn/p/12327196.html
Copyright © 2011-2022 走看看