Adding an image to a pdf with pdftk

前端 未结 4 2155
走了就别回头了
走了就别回头了 2021-01-31 11:36

Hello I am using pdftk to generate a PDF based on a form that is submitted.

I have everything working fine until here. Which is adding an image of a signature. I am usi

4条回答
  •  情书的邮戳
    2021-01-31 11:46

    In our case, we have to add dynamic signature in pdf. I have implemented it using pdftk and imagemagick libraries. (Require to install pdftk and imagemagick)

    1. First convert the image to pdf as: (Use magick instead of convert for windows)

    exec("convert signature-image -resize 26% -transparent white -page a4+25+102 -quality 75 outputs/stamp.pdf");

    Descriptions:

    • resize : adjust the size of image.
    • transparent makes image background transparent
    • page : set page to a4 and (25,102) sets the position of image pdf from left and top.

    2.Then execute following command:

    exec("pdftk main.pdf multistamp stamp.pdf output outputs/final.pdf");

提交回复
热议问题