Page 1 of 1
draw on a specific pdf page
Posted: 2011-11-11T03:42:33-07:00
by arno
I have a command like this:
Code: Select all
mogrify -density 300 -compress ZIP -fill none -stroke green -strokewidth 5 -draw 'rectangle 200,200 800,300' Page.com.pdf
With this it creates a nice rectangle. However, if my pdf has more then 1 page, it draws on all of them. If i specify a page number it deletes the rest of the pages.
Code: Select all
mogrify -density 300 -compress ZIP -fill none -stroke green -strokewidth 5 -draw 'rectangle 200,200 800,300' Page.com.pdf[0]
Is it possible to apply the changes to a specific page without deleting the rest?
Re: draw on a specific pdf page
Posted: 2011-11-13T22:24:02-07:00
by anthony
First please note that Imagemagick is not designed for vector images like PDF!
It can do it, but you need a lot of care and understanding of what is going on to get acceptable results.
See A word about Vector Image formats
http://www.imagemagick.org/Usage/formats/#vector
Having said that. Yes you can!
You find can not use mogrify. But convert. You read in the PDF, extract the old page into parenthesis, modify it ans then replace the original page.
See Combining Image Sequence Operations
http://www.imagemagick.org/Usage/basics/#seq_combine
Re: draw on a specific pdf page
Posted: 2011-11-14T03:22:23-07:00
by arno
Thanks! I'm using scans, so the pdf is already araster image in a pdf. I almost got it working. Next problem appears. I tried both commands (the enters mine for readability. Original command doesn't have enters):
Code: Select all
convert -density 300 -compress ZIP file1.pdf \( -clone 0 -fill none -strokewidth 9 -stroke blue -draw 'rectangle 1595,289 1876,342'
-stroke purple -draw 'rectangle 250,1188 1077,1266'
-stroke green -draw 'rectangle 399,1873 1946,1930' \)
-swap 0 +delete -append file2.pdf
Code: Select all
convert -density 300 -compress ZIP file1.pdf \( -clone 0 -fill none -strokewidth 9 -stroke blue -draw 'rectangle 1595,289 1876,342'
-stroke purple -draw 'rectangle 250,1188 1077,1266'
-stroke green -draw 'rectangle 399,1873 1946,1930' \)
-delete 1 -insert 1 -append file2.pdf
The original has 2 pages, the result has got 1 long page. I'm using this with pdf and multiple-page tiff's. I tried '+repage' and '-page a4' but that doesn't seem to affect the result.
Edit - NVM, deleting -append wasn't that difficult.
Re: draw on a specific pdf page
Posted: 2011-11-14T20:25:01-07:00
by anthony
Remove the append! That was just for the example for its results display.