Substitute for PDFTK for Fedora (watermark)

asked 2018-04-26 15:38:09 -0500

The ideal substitute for the command for pdftk is pyPdf. Below an example of use:

from pyPdf import PdfFileWriter, PdfFileReader

output = PdfFileWriter() input1 = PdfFileReader(file("text.pdf","rb")) watermark2 = PdfFileReader(file("watermark.pdf","rb"))

add page 1 from input1, but first add a watermark from another pdf:

page0 = input1.getPage(0) page0.mergePage(watermark2.getPage(0)) output.addPage(page0)

finally, write "output" to document-output.pdf

outputStream = file("watermarket_text.pdf", "wb") output.write(outputStream) outputStream.close()

finally, write "output" to document-output.pdf

outputStream = file("formulario_assinado.pdf", "wb") output.write(outputStream) outputStream.close()

edit retag flag offensive close merge delete