coherentgraphics / cpdf-binaries

PDF Command Line Tools binaries for Linux, Mac, Windows
GNU Affero General Public License v3.0
593 stars 42 forks source link

Stamp replace images #15

Closed Frolanta closed 7 years ago

Frolanta commented 7 years ago

I’m using your tool to stamp multiple pdf into one big pdf at specific coordinates. My issue is sometime there are images embedded on those files and is seems there is a problem with that. After the stamp all images (on the big pdf) are replaced with the image of the stamp.

Is guess that’s because they have the same name (Im0) and after the stamp there are renamed aIm0

./cpdf -image-resolution 30000 out-12.pdf 1, /aIm0, 498, 1033, 200.902220, 200.902220 1, /aIm0, 498, 1033, 200.902220, 200.902220 1, /aIm0, 498, 1033, 197.830693, 197.830693 1, /aIm0, 498, 1033, 85.698914, 244.084083 1, /aIm0, 498, 1033, 206.657406, 206.657406 1, /aIm0, 498, 1033, 204.113852, 204.113852 1, /aIm0, 498, 1033, 204.113852, 204.113852

There is an exemple: Big file: before

Stamp: stamp

Command: ./cpdf -stamp-on rotated-fixed-11.pdf -relative-to-cropbox -pos-left "311.8110236219 680.3149606295999" out-11.pdf -o out-12.pdf

Result: after (The one that are not replaced do not use images)

This is what I get when inspecting the file with acrobat: screen shot 2017-04-04 at 11 08 09

I can edit image(154) with photoshop and it confirm all the images have been replaced by the one on the stamp.

I’m using the OSX binary and all my pdf are version 1.5

Am I missing something or ?

files used: out-11.pdf rotated-fixed-11.pdf

johnwhitington commented 7 years ago

I think this should be fixable. But I will need to see the start of the process, where cpdf first gets involved. It looks like out-11.pdf has already been processed by cpdf.

Can you provide original files which have not been processed by cpdf, and exhibit a command, or series of commands, which leads to a file containing duplicate image names?

Frolanta commented 7 years ago

Yes you are right, there has been multiple stamps and rotations performed on out-11.pdf Here a complete process with originals files.

./cpdf -rotate 270 1.pdf AND -upright -o rotated-0.pdf
./cpdf -stamp-on rotated-0.pdf -relative-to-cropbox -pos-left "992.1259842515 0" out-0.pdf -o out-1.pdf

./cpdf -rotate 270 2.pdf AND -upright -o rotated-1.pdf
./cpdf -stamp-on rotated-1.pdf -relative-to-cropbox -pos-left "566.929133858 0" out-1.pdf -o out-2.pdf

Files: 1.pdf 2.pdf out-0.pdf

johnwhitington commented 7 years ago

FIxed in trunk camlpdf.

https://github.com/johnwhitington/camlpdf/commit/83499533a4195fda9e61a8d05b35eaaa97331c51

Frolanta commented 7 years ago

Great, when do you think this will be available in cpdf ?

johnwhitington commented 7 years ago

You can compile it from source yourself, by picking the trunk versions of camlpdf and cpdf, or you can wait for the next release in a year or so.

Or, if you're a paying customer, we can provide a binary build straight away.

Frolanta commented 7 years ago

Working great, thanks.