14

My OS is Ubuntu. So I prefer Linux/Debian software, but any Windows software that can run under Wine or mono would be okay too.

I have a scanned pdf file which is an application form, and a picture which is the scanned version of one's signature (for example, this one) and can be in any image format such as eps or png. I would like to put the signature picture on the blank space right to "APPLICANT:" on the second page of the application form. I wonder how to do that?

I have tried the following methods, but none succeeded.

  1. The first way is using gimp. I first import the application form into gimp, and then paste the signature picture on the space right to "APPLICANT:" on the second page of the application form.

    But the problems are that:

    • It seems that I can only import one page of the application form into gimp, not all of the two pages.

    • Also when I save the modification, the closest format to pdf I can save to is ps, and the resolution has been downgraded and the storage size of the saved file is 10 times bigger than the original application form and the signature picture.

  2. The second way is using Libreoffice Draw. I have installed the libreoffice-pdfimport package. But after I import the application form into Libreoffice Draw,

    • all the scanned content is not imported, and

    • the layout is different from the layout of the original application form.

So what other ways can I try? I would prefer some way that can lay the signature picture directly on the application form pdf file,

  • without having to convert between formats,
  • without having to create much bigger files while keeping the original resolution,
  • without having to split and combine pages of a multi-page pdf file,
  • without having to rasterize other parts of the pdf file, i.e. without losing the text I later added to the application form pdf file by having to convert the whole pdf into images.

Thanks!

9 Answers 9

14

I would do it like this:

  1. Create a blank page PDF with just the signature in the lower left corner on it. If you wanna be fancy, make the signature blue or red or green.... Important: the page should use a transparent background, not a white one! Keep this around as the "master-sig.pdf".

  2. Use Ghostscript to convert the "master-sig.pdf" into a new "working-sig.pdf" page, with the signature shifted to the spot where you need it:

    gs -o working-sig.pdf \
       -sDEVICE=pdfwrite \
       -c "<< /PageOffset [216 504] >> setpagedevice" \
        master-sig.pdf
    
    This one would shift the signature by 3 inches to the left, and 7 inches to the top (72 points in PostScript == 1 inch on a ruler). You'll have to experiment a bit, or apply a hardware ruler on the piece of paper printout (plus some algebra) to determine the correct numbers.

  3. Use pdftk to overlay the "working-sig.pdf" onto your "contract.pdf" with the result as "signed-contract.pdf"

    pdftk \
        contract.pdf \
        stamp   working-sig.pdf \
        output  signed-contract.pdf
    
2
  • 2
    In the current version of Ghostscript (9.50), I've had to tweak the command line syntax to make the first command work (your mileage may vary), I had to add -f before the input argument: gs -sDEVICE=pdfwrite -o working-sig.pdf -c "<< /PageOffset [216 504] >> setpagedevice" -f master-sig.pdf.
    – Manu
    Jun 10, 2020 at 14:15
  • 1
    You can combine 1 and second step using ghostscrip too gs -o A4-image.pdf -sDEVICE=pdfwrite -g5950x8420 -r300x300 -c "<</PageOffset [100 500]>> setpagedevice" -f image.pdf whereabout -g is resolution in pixel width/height -r is DPI and PageOffset is left bottom, units in points
    – fearis
    Nov 22, 2022 at 18:25
6

This was annoying me, so I made a small package called pdfstamp to make it easier.

https://github.com/benwinding/pdfstamp

Install

npm i -g pdfstamp

Ensure you have dependencies (ImageMagick and pdftk)

pdfstamp doctor

Usage

pdfstamp stamp \                                                                                                      
--input ./input.pdf \                                                                                  
--signature ./signature.png \                                                      
--output ./output.pdf \                                
--page 2 \                       
--bottom 300 \
--left 200

enter image description here

2
  • Love the idea, and I upvoted. But I found some bugs. Positioning is not really working unless I zoom to 100%. Also the "doctor" mode doesn't really work.
    – PJ Brunet
    Apr 30, 2023 at 6:39
  • Thanks PJ, will hopefully get time to fix it soon 👍 May 1, 2023 at 6:34
5

The LibreOffice provided answers don't keep the appearance of the text.

Use LibreOffice Writer, but this way:

  1. Create a new LibreOffice Writer document;
  2. Remove margins through Format → Page;
  3. Import each PDF page through Insert → Image;
  4. You can lay any image over the inserted (original) ones.
1
  • straight forward, easily available. Thanks. Addition: Nowadays in Draw there is no Format->Page anymore. You have to search for slide and adjust the paper size and margin there.
    – Jan
    Jul 14, 2022 at 10:39
4

If you are using Ubuntu:

sudo apt-get install pdfedit

To start PDFEdit, type:

$ pdfedit /path/to/pdf.file &
$ pdfedit &

This will give you use of a PDF editor to fix your problem.

This software is a WYSIWYG visual editor that also supports scripting and almost anything can be scripted. PDFedit is a low-level tool for users. You can use this software:

To write / create / edit PDF files.

Print PDF files.

Save PDF files.

Export PDF files to XML etc.

3
  • 1
    Can you please give a short description of how pdfedit works, to solve the problem?
    – user3463
    Jul 24, 2012 at 3:12
  • 1
    Thanks! As @Randolph said, could you explain how pdfedit can add a picture onto an existing pdf file?
    – Tim
    Jul 24, 2012 at 3:30
  • 1
    pdfedit is no longer available in the Ubuntu repositories.
    – David
    Jun 23, 2023 at 10:48
4

As of 2018, pdfedit is no longer in any repositories, but happily LibreOffice Draw (likely installed on Ubuntu already, or easy to get through your distribution's package manager) now works very well to edit text on most PDFs (for instance to fill in forms) and to insert images (for instance to paste in your signature).

1
  • 1
    Exporting to PDF from LibreOffice Draw doesn't keep the original PDF links working. Mar 16, 2023 at 1:34
1

Forget about LibreOffice Draw. Use LibreOffice Writer. I've got the entire process written in a blog post over at http://colans.net/blog/signing-document-image-ubuntu-1210 .

1
  • The tutorial presents LibreOffice Draw and not Writer. Anyway, on my computer LibreOffice automatically switches to Draw when I want to open a PDF.
    – Eric M.
    Jan 15, 2021 at 17:18
1

I've recently (January 2024) reviewed the alternatives for PDF editing in Linux, and I'm happy to say that at last we have an effective user-friendly option: Xournal++, “a handwriting notetaking software with PDF annotation support”. PDF rendering support is excellent, and the UI is comparable to that of LibreOffice Draw. The only warning is that you should definitely install the latest stable release, since even slightly outdated versions tend to be a little buggy. This is especially true for Ubuntu LTS and derivatives which tend to trail behind upstream repositories.

To install the latest stable release of Xournal++ to Ubuntu, open a terminal session and enter the commands below:

sudo add-apt-repository ppa:apandada1/xournalpp-stable
sudo apt update
sudo apt install xournalpp

Once Xournal++ is installed, PDF files can be opened from the main menu by selecting File -> Open, or by using the Ctrl+O shortcut. Common editor options include:

  • Add Image: Tools -> Image or Shift+Ctrl+I — then click on the location where you want to add an image. A file selection dialog will automatically open. Once the image is added it can be freely moved and scaled. If you want to scale an image while keeping its proportion, click and drag one of the corners of the image bounding box; to scale without maintaining proportion, click and drag from the middle of one of the sides.
  • Add Text: Tools -> Text or Shift+Ctrl+T — then click on the location where you want to add a text box. Font face, size and effects (i.e. italic and / or bold) can be selected from a tool bar drop down. The text box expands in response to the amount of text; line breaks can be added manually.
  • Select Rectangle: Tools -> Select Rectangle or Shift+Ctrl+R — allows previously added elements to be selected, moved and copied / pasted (with Ctrl+C / Ctrl+V).

Notice that when a tool is selected, it remains active until something else is selected — for example, if Add Image is selected, the file selection dialog will open every time you click the document. It's good practice to manually revert to Select Rectangle every time a new element is added to the document, to avoid surprises.

After completing the desired edits, File -> Export as PDF can be used to export the whole document with the changes. To export just the modifed page(s), you can use File -> Print, select Print to File and specify the desired page(s). Also remember to set the destination file path, which defaults to ~/Documents/output.pdf.

2
  • Great answer! Just wanted to add that ``sudo apt install xournalpp'' is enough, as the official repositories include the latest stable version. Mar 7 at 16:13
  • Back when I posted this answer the version in the official Ubuntu repository had a bug in the Add Image feature, which would sometimes cause images to be duplicated whenever they were moved or resized. That's why I recommend installing from the project repository.
    – xperroni
    Mar 8 at 15:53
0

I've had a reasonably good experience with uPdf.

Installation

sudo add-apt-repository ppa:atareao/updf
sudo apt-get update
suod apt-get install -y updf

Then fix a bug by editing 2 lines in a Python script.

Usage

Launch uPdf, select the Add an image tool, draw a rectangle around the area where you want the signature to go and select the image file with your signature. A PNG with a transparent background works best.

-1

Use pdflatex/xelatex/lualatex. These programs can read images and pdfs and create new pdfs.

4
  • 1
    My question is that how do you place the picture at some particular location on the pdf file?
    – Tim
    Jul 24, 2012 at 22:32
  • @Tim: Put one picture in the background and put the other on top of it; the picture environment and the textpos package can do that. I suggest to take your question to tex.stackexchange.com . Jul 25, 2012 at 5:48
  • There you go
    – Tim
    Jul 25, 2012 at 11:38
  • 2
    Very lazy answer, would downvote if I could. May 1, 2020 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .