2

I have been blessed in the context that many a times if I come across some interesting content, debate etc. which involves some pdf, more often than not I have the author mailing me the content/pdf or sending me the same on IM or whatever. Over period of time I forget the context or who sent the content to me. While I do not know the limits but I'm pretty sure that at least couple of fields can be added. As an e.g. here is metadata of a pdf file I am currenly viewing.

File Size                       : 3.6 MB
File Modification Date/Time     : 2019:11:24 01:11:52+05:30
File Access Date/Time           : 2019:11:24 01:12:00+05:30
File Inode Change Date/Time     : 2019:11:24 01:11:54+05:30
File Permissions                : rw-r--r--
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.4
Linearized                      : No
Page Count                      : 54
Producer                        : Mac OS X 10.11.6 Quartz PDFContext
Creator                         : LaTeX with hyperref package
Create Date                     : 2018:05:01 19:56:31Z
Modify Date                     : 2018:05:01 19:56:31Z

Now I ask a way in which I could add fields such as hyperlink (so I can remember from where I downloaded the specific file) or from : [email protected] so I alwaqys can know/refer to or find out even at later date who shared the content/pdf file with me. I did see the manpage for pdftk or rather pdftk-java which is there in Debian. There is something called update_info but the example shared does not make it easy for me to understand how is one supposed to use that. Could somebody help ?

0

2 Answers 2

5

First of all you have to export the metadata of the file in question. The command

pdftk file.pdf dump_data output metadata

will generate metadata, a file containing all the metadata of file.pdf. Inside this file you will find structures of the following form:

...
InfoBegin
InfoKey: Creator
InfoValue: pdftk 3.0.2 - www.pdftk.com
...

You can create your own metadata key by adding the lines

InfoBegin
InfoKey: Hyperlink
InfoValue: [email protected]

to the file. Finally, you need to update the metadata of file.pdf with

pdftk file.pdf update_info metadata output file2.pdf

Note that the latter generates a new file file2.pdf. Now, you have two files: file1.pdf without the added metadata and file2.pdf with your custom metadata key. You can check if everything went well with the exiftool command which returns

...
Hyperlink                       : [email protected]
Modify Date                     : 2019:10:08 18:42:36+02:00
Creator                         : pdftk 3.0.2 - www.pdftk.com
Create Date                     : 2019:10:08 18:42:36+02:00
...
3
  • the generated file metadata generated a binary file, I get output such as paste.debian.net/1117957. Where would the above structures be at, is there a specific place where these stuctures are supposed to be, at the end or the beginning ?
    – shirish
    Commented Nov 26, 2019 at 0:31
  • Sorry I forgot something on the first command line expression. The command you need to enter is pdftk file.pdf dump_data output metadata. The structure can be added anywhere in the file.
    – user382051
    Commented Nov 26, 2019 at 0:37
  • ah, that makes more sense. Yeah, now I can see that. I'll try as you shared above and tell you if it worked or not in few hrs. going to sleep for few hrs. now.
    – shirish
    Commented Nov 26, 2019 at 1:50
0

You can use pdftk to strip all Info and XMP metadata from a document by copying its pages into a new PDF, like this:

pdftk A=mydoc.pdf cat A output mydoc.no_metadata.pdf

1
  • You will need to install the pdftk-java package in Debian as pdftk is no longer free. Commented Jul 18, 2021 at 19:23

You must log in to answer this question.

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