Adding an image to a pdf with pdftk

前端 未结 4 1915
走了就别回头了
走了就别回头了 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:58

    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");

    BUT TO LOCATE SIGNATURE TO SPECIFIC POSITION ADD SOME BLANK PDF BEFORE SIGN PDF AS SHOWN BELOW:

    exec("convert signature-image -resize 26% -transparent white -page a4+25+102 -quality 75 outputs/stamp.pdf");
                exec("convert xc:none -page A4 outputs/blank1.pdf");
                exec("convert xc:none -page A4 outputs/blank2.pdf");
    exec("convert xc:none -page A4 outputs/blank3.pdf");
                exec("pdftk outputs/blank1.pdf outputs/stamp.pdf outputs/blank2.pdf  outputs/blank3.pdf cat output outputs/sign.pdf");
              exec("pdftk main.pdf multistamp outputs/sign.pdf output outputs/final.pdf");
    

提交回复
热议问题