I have a code.ps file converted to code.pdf , which I want to add to the end of every page in my test.pdf , i.e shrink the test.pdf's every page and add an image to the end of it .
I have written the following shell script to it , but it appends the code.pdf as a new page after every page of test.pdf ! ...Kindly help . Here is my code :-
#!/bin/sh
filename=test.pdf
pages="`pdftk $filename dump_data | grep NumberOfPages | cut -d : -f2`"
numpages=`for ((a=1; a <= $pages; a++)); do echo -n "A$a B1 "; done`
pdftk A=$filename B=code.pdf cat $numpages output $filename-alternated.pdf
exit 0
A simple example of stamping an image (image.[pdf,png] onto a multipage pdf (text.pdf) allowing for manual tweaking of the scaling and offsets using pdfjam
and pdftk
could be:
# scale and offset the text part
pdfjam --scale 0.8 --frame True --offset '0cm 2.5cm' text.pdf
# scale and offset the image
pdfjam --paper 'a4paper' --scale 0.3 --offset '7cm -12cm' image.pdf
# combine both
pdftk text-pdfjam.pdf stamp image-pdfjam.pdf output combined.pdf
This might look like
If you start with an image file (png, jpg) you can convert it to pdf using imagemagick like
convert image.png image.pdf
Of course, the scale factors and offsets have to be adjusted to your needs. I included the --frame
option to highlight the scaling of the text.pdf part. The stamp
option overlays the image, whereas the background
option would underlay the image.
来源:https://stackoverflow.com/questions/20235541/add-a-pdf-file-png-basically-to-the-end-of-every-page-in-another-pdf-file