Unfortunately, I don't think IM will parse the %p directly into 
-draw. You need to store that in a shell variable. But I don't know 
that IM will know what page you have in the pdf. I don't work with 
them often.

For example try:

page=`convert testin.pdf -format "%p" info:`
convert testin.pdf -draw 'text 100,100 $page'  testout.pdf

This might work in one step:
convert testin.pdf -draw 'text 100,100 $(convert testin.pdf -format 
"%p" info:)  testout.pdf


Try it with %t rather than %p to see if it recognizes the top of the 
file name, if it does not work because IM cannot figure out the page 
number in the pdf.




>I am trying to add displayed page number to a pdf.  The problem is 
>that the draw command is not expanding the variables.  I am not sure 
>what I am doing wrong.  I am ending up with the literal "%p" rather 
>than the actual page number.  I have tried a few different things like 
>this:
>
>convert testin.pdf -draw 'text 100,100 "%p"'  testout.pdf
>
>If I do it this way: convert testin.pdf -draw 'text 100,100 %p'  
>testout.pdf
>then I get an error:  convert: Non-conforming drawing primitive 
>definition `p'.
>and my image just has a literal %.
>
>Just to make sure that it was not an issue with gs and pdfs I also 
>tried a few tests with jpgs and got the same results.
>
>I do know that montage is correctly adding labels so things like this 
>do work:
>montage -label "%f" *.jpg output.jpg
>
>What am I doing wrong?  How can I add page number to a pdf?
>
>I am using ImageMagick 6.4.2-7 on a Mac, and using the Bash shell.
>
>Thanks much.
>
>--Adam
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to