2

I'm trying to stamp one PDF file (multiple pages) with another (single page) PDF file by using pdftk stamp operation.

    pdftk large.pdf stamp stamp.pdf output stamped.pdf

Now, stamp.pdf contains a single page with a single line of text at the bottom of the page. That text is a hyperlink (that is, a pdfmark link annotation is located above that line of text). Newly created stamped.pdf is properly stamped but hyperlink is not present anymore - it seems that stamp operation (and multistamp, and also background and multibackground operations) is, for some reason (?), stripping this hyperlink annotation.

Does anyone know how to circumvent this?


I've tried this on multiple distros and results are the same (Debian 6.0, Ubuntu 12.04, CentOS 6.4 - pdftk versions 1.44 and 1.41).

Please note that hyperlinks in large.pdf are preserved in output stamped.pdf.

Solution like converting large.pdf to PS and then adding links to each page in PS and then converting back to PDF is not an option as that takes a really long time compared to pdftk stamping (in my case it takes something like 10-20 seconds - depending on large.pdf size, while pdftk completes stamping in 1 second).

I'm also interested in any other Linux command-line based tool for stamping one PDF with another PDF (or PS).

Thanks.


EDIT

I tested with latest version of pdftk (2.02) and the results are the same - links are stripped.

I tested stamping functionality with some other (non-free) tools as well - Coherent PDF and VeryPDF - both are stripping links. So, I guess it's either something that is overlooked or there is some technical difficulty in maintaining hyperlink annotations in stamping PDF.

pbradaric
  • 21
  • 3
  • That is not really a programming related question, is it? – AnyOneElse Sep 19 '13 at 12:35
  • Well, I'm currently writing PHP application that utilizes pdftk (among other things) to stamp PDFs. So, my inclination was to post a question here - although, technically, I guess you are right. Should I "move" this to i.e. superuser? – pbradaric Sep 19 '13 at 19:09

2 Answers2

0

Appearantly you can't do it that way. This answers the question why: "Stamp PDFs" are flattened and stripped, so all extra information is lost.

Source http://forum.planetpdf.com/wb/default.asp?action=9&fid=103&read=58551

AnyOneElse
  • 406
  • 2
  • 6
  • 17
  • Interesting read. Post also hints how one would go about adding hyperlink annotations using libraries that pdftk uses (PdfStamper). – pbradaric Sep 19 '13 at 19:07
0

It would be possible for a program to combine both sets of hyperlinks, but as you've noticed, pdftk doesn't do that, and neither do the Coherent PDF tools (which I wrote).

You can add a bug report here, and we will put it on the list of things to do:

cpdf bug reports

There are lots of things to combine when stamping: fonts and resources need to be renamed so as not to clash, bookmarks need to be merged, etc. Some tools do all of this, some just a little, and some just the minimum.

Maybe you could find a tool which can add a hyperlink given a URL and a rectangle, and then do it after the stamping?

johnwhitington
  • 2,308
  • 1
  • 16
  • 18
  • I've searched for the tool to add hyperlink annotations after the stamping - unfortunately nothing found so far. Btw., the link for your project on Github is wrong - should be [this](https://github.com/johnwhitington/cpdf-source). Will fill a bug report there. Thanks. I'm also now thinking of trying my luck on adding the feature myself - either to your cpdf or pdftk. – pbradaric Sep 19 '13 at 19:01
  • The closest I know is CTAN `pax` package: https://www.ctan.org/pkg/pax?lang=en - that seems to be unmaintained, though. – Mikko Rantalainen May 04 '16 at 06:44