The problem is the same as in ImageMagick. I am trying to convert pdf file into png -- in GS instead of converting I am printing the file. And the problem is, no matter what I do, in result I get the image but with huge white border, the image itself is pushed into lower, left corner. It is easiest to see in this example, single page pdf, whole page is black, 300 dpi: http://www.imagebam.com/image/699efd25471451 I execute: gs -q -sDEVICE=pnggray -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 -r300 -sOutputFile=black.png black.pdf 2>&1 I should get the same black rectangle, instead I get this: http://www.imagebam.com/image/c27a9126403474 One note: from what I see specifying the density is irrelevant here, the image gets bigger or smaller, but the white border remains. [ sorry if the component is wrong, this is my first report at this site ]
I guess, you need to use -dUseCropBox option but it's hard to tell without a sample PDF file. If -dUseCropBox doesn't work for you, please attach your PDF file to the bug report.
The result is changed, but there is still some white leftovers. Attachment follows (btw. this pdf is from converting black png image into pdf).
Created attachment 4788 [details] black.pdf
Created attachment 4790 [details] gs-black.png Seems to work for me. Attaching the output of $ bin/gs -dUseCropBox -r300 -sDEVICE=pnggray -o gs-black.png black.pdf I do see a small white border looking at the attached pdf in evince. The image matrix does look incorrect to fill the crop box: /MediaBox [0 0 640 400] /CropBox [0 0 154 96] ... 153.6 0 0 96.0002 0 0 cm /Im0 Do If I change the matrix to match the CropBox dimensions, the remaining border goes away.
The white remains are identical to mine when I added cropbox. But you have to modify the matrix by hand, so it is a workaround, not a solution (but thank you for the tip). My point is -- it should be automatic. I can convert png to pdf file 100% automatically, and the result is identical to the source. Now, I should be able to do the same with converting pdf to png.
My claim in #4 is that the pdf is not 100% identical to the source png. The problem is that the file draw the image slightly smaller than the CropBox; Ghostscript appears to be rendering that faithfully. Perhaps Imagemagick is rounding the CropBox but not the image matrix. Or just rounding the two differently. In printing, it is common to extend the border colours outside the CropBox (so-called "full bleed") to avoid issues like this. Especially since an actual physical crop is unlikely to be precise. Imagemagick doesn't seem to be doing this either. If you know the border colour you might be able to work around by adding '-background black', for example, to your convert command line.
Adobe Acrobat 8 and 9 both show the white line along the right hand side, the same as Ghostscript. We are correctly rendering the PDF, closing as WORKSFORME
Ok, I just want to ensure -- the problem with printing .pdf to .png using GS is caused by incorrectly constructed .pdf file (by ImageMagick)? Did you understand you right? (if yes, I think it would be the best to post a report again IM but for .png -> .pdf conversion, and after the fix in IM test it again in GS for .pdf -> .png "printing").
Yes, the problem you're having is from Imagemagick. Ghostscript is rendering the created pdf correctly.