mariachi wrote:This will draw a black rectangle on top of the name and it's placed correctly on the first page, but the second page has less white space on the top margin, so the rectangle is slightly below the name. How can I draw the second second for the second, third, "n" page with coordinates slightly above the ones from the first page?
I'm using ImageMagick 7 on a Windows 7 64 computer. I worked out a solution that will work with ImageMagick 7 on Windows, but probably not with IM6 or earlier versions.
This uses a "for" loop to run through all the PDF files in the folder, and creates output files with their original names in a folder named "done".
Code: Select all
for %I in ( *.pdf ) do (
magick ^
-density 300 ^
"%I" ^
-set filename:f "%[t]" ^
-fill black ^
-stroke black ^
-strokewidth 5 ^
-draw "rectangle 1500,%[fx:(t==0?40:0)+650] 2300,%[fx:(t==0?40:0)+730]" ^
-compress zip ^
"done/%[filename:f].pdf"
)
The "-draw" operator uses an FX expression to place the black rectangle 40 pixels lower on only the first page. The "t" in the FX expression stands for the page number, starting with 0 for the first page, and if it is zero it adds 40 pixels to make the vertical location of the rectangle lower than on the rest of the pages.
That output folder "done" must already exist, but if you're using a batch file you could create it ahead of the "for" loop.
If you put this command in a batch file you'll need to make all the single percent signs "%" into doubles "%%".