2

I have two PDFs from two different sources that are exactly the same size. I want to overlay one on top of the other.

Output from pdfinfo -box -f 1 -l 3 top.pdf:

Creator:        cairo 1.10.2 (http://cairographics.org)
Producer:       cairo 1.10.2 (http://cairographics.org)
Tagged:         no
Pages:          1
Encrypted:      no
Page    1 size: 419.2 x 594.4 pts
Page    1 MediaBox:     0.00     0.00   419.20   594.40
Page    1 CropBox:      0.00     0.00   419.20   594.40
Page    1 BleedBox:     0.00     0.00   419.20   594.40
Page    1 TrimBox:      0.00     0.00   419.20   594.40
Page    1 ArtBox:       0.00     0.00   419.20   594.40
File size:      1023501 bytes
Optimized:      no
PDF version:    1.5

output from pdfinfo -box -f 1 -l 3 bg.pdf:

Producer:       GPL Ghostscript 9.05
CreationDate:   Wed May 21 16:00:30 2014
ModDate:        Wed May 21 16:00:30 2014
Tagged:         no
Pages:          1
Encrypted:      no
Page    1 size: 419.2 x 594.4 pts
Page    1 MediaBox:     0.00     0.00   419.20   594.40
Page    1 CropBox:      0.00     0.00   419.20   594.40
Page    1 BleedBox:     0.00     0.00   419.20   594.40
Page    1 TrimBox:      0.00     0.00   419.20   594.40
Page    1 ArtBox:       0.00     0.00   419.20   594.40
File size:      145877 bytes
Optimized:      no
PDF version:    1.4

The command I'm using to overlay is: pdftk bg.pdf stamp top.pdf output test.pdf

As you can see from the attached test.pdf the top.pdf is cropped before being stamped onto the image. If I stamp two PDFs from the same source it works without cropping. However all the PDFs are exactly the same size! Any ideas?

http://image.secureweb.ie/pub/bg.pdf
http://image.secureweb.ie/pub/top.pdf

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
mmcg
  • 23
  • 4
  • http://image.secureweb.ie/pub/test.pdf – mmcg May 21 '14 at 16:27
  • Unfortunately, `pdfinfo` does not *always* display the Crop-/Bleed-/Trim-/ArtBox values as they are specified inside the PDF file. In cases were these values do not make any sense (or are 'illegal' or are not specified at all), `pdfinfo` instead displays values which it falls back to in lieu of the nonsense values from the file (that is, it uses the same ones that are used for MediaBox). – Kurt Pfeifle Jul 31 '14 at 13:48

1 Answers1

2

The tools you are using are not the best you could choose. They are giving you false information. I have opened your three files in iText RUPS, and this is what I see:

enter image description here

From left to right, we see:

  • bg.pdf with a MediaBox with value [0 0 419.2 594.4] and a CropBox of [-8.665 -8.94 427.87 603.343]. This is, of course, wrong: the CropBox can't be bigger than the MediaBox.
  • top.pdf with a MediaBox with value [0 0 419.200012 594.400024] and no CropBox
  • test.pdf with the same values for the MediaBox and the CropBox as bg.pdf

I would fix the CropBox value before manipulating the PDFs.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • 2
    Spot on Bruno. I ended up using Podofo to remove the CropBox and it worked. http://en.wikipedia.org/wiki/Podofo – mmcg May 22 '14 at 12:57