I have many files of music; with the program mp3Tag, I had organized all of it. I have the correct metadata as it allows. I am looking for a free software that does the same, but for PDF files.
-
2askubuntu.com/questions/27381/…– user1133275Commented Dec 16, 2018 at 5:00
-
Please modify your question title. You are NOT interested in the internals of PDF format, it seems, but rather in the names of free s/w which might help you modify pdf metadata. I'm not even sure if it's linux related at all, from the way this question is worded.– Dani_lCommented Dec 23, 2018 at 20:29
-
I am Latin, sorry for bad sense fo question. I am in Win10, but I want to know that's too. Win10 shows many columns with Author, Year, and I thinks is for PDf and relationed.– Jaaziel AguirreCommented Dec 29, 2018 at 4:11
3 Answers
Ghostscript can insert or modify document metadata into any PDF.
Caveats: While doing so, Ghostscript will (1) first read in the complete PDF code, (2) second re-process that complete PDF code, (3) write out a completely new PDF file. This process can be wanted (could be for the advantage of the PDF quality, for example by additionally embedding previously missing fonts) or unwanted...
How to do it
Create a text file named mydocinfo.pdfmark and put the following content into it:
[ /Title (Jaziel's Important Document) /Author (Jaziel Aguirre) /Subject (Mr. Aguirre's experiments with pdfmark) /Creator (JA's Metadata Inserter) /ModDate (D:19700101000000+01'00') /Producer (A 'pdfmark' trick with Ghostscript) /Keywords (Metadata, Ghostscript, PDF, Linux) /CreationDate (D:20181229104653+01'00') /DOCINFO pdfmark
Note, that the opening
[
does NOT require a closing]
-- it is closed by the 'pdfmark' keyword.Now run this Ghostscript command to insert the new metadata into an existing PDF:
gs \ -o with-metadata.pdf \ -sDEVICE=pdfwrite \ existing.pdf \ mydocinfo.pdfmark
Check the new metadata:
pdfinfo with-metadata.pdf Title: Jaziel's Important Document Subject: Mr. Aguirre's experiments with pdfmark Keywords: Metadata, Ghostscript, PDF, Linux Author: Jaziel Aguirre Creator: JA's Metadata Inserter Producer: A 'pdfmark' trick with Ghostscript CreationDate: Sat Dec 29 10:46:53 2018 CET ModDate: Thu Jan 1 00:00:00 1970 CET Tagged: no UserProperties: no Suspects: no Form: none JavaScript: no Pages: 1 Encrypted: no Page size: 142.8 x 202.08 pts Page rot: 0 File size: 5394 bytes Optimized: no PDF version: 1.7
(Tested with Ghostscript v9.27.)
-
1what a useful, I will do this in some future. thanks Commented Dec 29, 2018 at 4:07
-
Mmm Yes, but i am new here, so, I click the up arrow of corner? Commented Dec 30, 2018 at 21:03
-
@JaazielAguirre: Exactly. Plus, you pick one (or none) of the answers to make it the "accepted" (best) answer for you... Commented Dec 30, 2018 at 22:28
-
Does this also allow to remove metadata? If yes, how? Commented Aug 6, 2021 at 7:39
-
1@holzkohlengrill: Yes, if you create the mydocinfo.pdfmark file with zero content inside the brackets, like this:
[ /Title () ....
Commented Aug 8, 2021 at 13:04
pdftk
is a command line utility allowing you to extract and modify the PDFs metadata using the dump_data
and the update_info
options.
The following command will extract the metadata of the input.pdf
to metadata
file:
pdftk input.pdf dump_data output metadata
Modify the content of the metadata
file using your text editor, then update the pdf file to a new output.pdf
:
pdftk input.pdf update_info metadata output output.pdf
To check the new pdf file (print to stdout):
pdftk output.pdf dump_data
-
1Ha!, I was thinking about adding pdftk's method a little bit later too. Now I can upvote your answer instead... :-) Commented Dec 22, 2018 at 20:13
-
Hey, that's is simple. thanks for response. My ask was for Win10 but it helps me for the future, I had problems with Computers and just now I have a Pc with only win10. thanks Commented Dec 29, 2018 at 4:05
-
The format of the
metadata
file created bypdftk
is hard to understand, so it's hard to edit. In mine there is no “title” nor “author” anywhere and if try to add one by mimicking what's already there,pdftk
does not seem to like it when I useupdate_info
. Does someone know where to find info on thedump_data
output format? Commented Sep 9, 2020 at 9:10
Instead of writing the metadata into a text file first, you could of course also put it into one single command line:
gs -o with-meta.pdf -sDEVICE=pdfwrite -f existing.pdf -c "[ /Title (Jaziel's Important Document) /Author (Jaziel Aguirre) /Subject (Mr. Aguirre's experiments with pdfmark) /ModDate (D:19700101000000+01'00') /CreationDate (D:20181120102653+01'00') /Keywords (Metadata, Ghostscript, PDF, Linux) /Creator (JA's Metadata Inserter) /Producer (A 'pdfmark' trick with Ghostscript) /DOCINFO pdfmark"
or, with a formatting which is a bit more nice (readable):
gs -o with-meta.pdf \ -sDEVICE=pdfwrite \ -f existing.pdf \ -c "[ /Title (Jaziel's Important Document) /Author (Jaziel Aguirre) /Subject (Mr. Aguirre's experiments with pdfmark) /Keywords (Metadata, Ghostscript, PDF, Linux) /ModDate (D:19700101000000+01'00') /Keywords (Metadata, Ghostscript, PDF, Linux) /Creator (JA's Metadata Inserter) /Producer (A 'pdfmark' trick with Ghostscript) /CreationDate (D:20181120102653+01'00') /DOCINFO pdfmark"