Closed hakt0-r closed 8 years ago
The only insight I can give is to confirm that cpdf has no way of moving the stamp, unless requested to by extra arguments. Are you sure you haven't mixed up your two stamps? For example, stamp/stamp.pdf
and `stamp.pdf'?
Maybe if you attach the correct result as well as the failing result, I can take a manual look at the two PDFs and tell you what the difference is...
Thanks for replying so quickly...
No I haven't mixed them up. If you create a folder and a subfolder called stamp, that is where I house my stamp.pdf. :-)
This is the expected output (see attached) expected.pdf
Just try using the files I have provided via the command line too, for me (now, surprisingly) they yield the same skew/offset result as the automator. I can swear that last night I was seeing a better output than now (but I could be mistaken here too). The expected.pdf is what is supposed to be produced given that the documents are merged/stamped.
If you open the stamp.pdf, you'll notice its the letterhead, the inv.pdf is a simple invoice that is created from a very old system and the result should be a merged PDF that looks like its been printed on the letterhead.
here are the source files and the tweaked stamp file too (to make it look like the stamp.pdf being overlaid on the inv.pdf) generated.pdf inv.pdf stamp_tweaked.pdf stamp.pdf
The generated.pdf is what I get when I use the this command (with these files) cpdf -stamp-on stamp.pdf inv.pdf -o generated.pdf
And after using the stamp_tweaked.pdf and this command line I get the fixed.pdf (this is what I want.) cpdf -stamp-on stamp_tweaked.pdf inv.pdf -o fixed.pdf fixed.pdf
Your stamp.pdf and inv.pdf have different page sizes:
feast:Downloads john$ cpdf -page-info stamp.pdf
Page 1:
Label:
MediaBox: 0.000000 0.000000 595.276001 841.890015
CropBox: 0.000000 0.000000 595.276001 841.890015
BleedBox: 0.000000 0.000000 595.276001 841.890015
TrimBox: 0.000000 0.000000 595.276001 841.890015
ArtBox: 0.000000 0.000000 595.276001 841.890015
Rotation: 0
feast:Downloads john$ cpdf -page-info inv.pdf
Page 1:
Label:
MediaBox: 0.000000 0.000000 612.000000 792.000000
CropBox:
BleedBox:
TrimBox:
ArtBox:
Rotation: 0
(The stamp is A4, whereas inv,pdf
is US Letter)
By default, cpdf
stamps at the bottom left of the page. You can get the result you want with:
cpdf -stamp-on stamp.pdf -top 0 inv.pdf -o out.pdf
Assuming your version of cpdf
is recent enough. I think the currently released version supports it, but let me know if it doesn't, and I can send you a new executable.
Well now I feel totally stupid :-p
Nice catch, it didnt occur to me that this was happening.
I do have the latest version of cpdf and when I ran the command you gave, it worked like a charm.
thanks for helping out. :-) much appreciate it.
inv.pdf invoice.pdf stamp.pdf
See the example files. The command line run is cpdf -stamp-out stamp.pdf inv.pdf -o invoice.pdf
If I run this on Terminal (OSX el Capitan) manually, I get the perfect result (not attached). If I run this via Folder Action Script --> Automator workflow, the attached invoice.pdf is the output. As you can see from the attached file, the stamp document is offset upwards by 3-4 linespaces.
This is my automator "Run Shell Script" action... (Pass Input as arguments & the shell is /bin/bash) for f in "$@" do fldr=$(dirname "$f") /opt/local/bin/cpdf -stamp-on "$fldr/stamp/stamp.pdf" "$fldr/inv.pdf" -o "$fldr/invoice.pdf" done
Its only when cpdf is via the automator's run shell script it messes up the offsetting of the stamp being applied on inv.pdf.
Any insight here will help.
PS: I have resolved this issue by editing my stamp.pdf and moving all objects in that pdf down by 4 linespaces (4 down arrow key presses).
I thought it'd be best to report this finding.