You cannot do this with InDesign.
I think for that you have to edit the PDF in Acrobat Pro at a very low level…
And you can wreck your PDF by doing the following:
To do that, the PDF should not be "optimized" or "encrypted" and you would open the PDF with an text editor app. Search for the string you want to change and exchange every instance of it with the new contents. Save the file as text only.
Do this always on a duplicate of the PDF.
Do not expect that the PDF will work as intended after editing.
If it does, you are lucky. Validate it with Acrobat Pro's Preflight feature thoroughly!
That said with all the warnings:
WHY on earth do you want to do this?
(Needless to say, that the editing process can be scripted by ExtendScript e.g. out of inDesign; I will give no further hints, because this is outright dangerous)
//Some edits made to this post.
thanks for the feedback!
Well, I have to do it because it is requirement.
The "feature" I am talking mainly converts Indessign files to PDF on Indesign Server using the scripts of course. The resulting PDF's have to be branded with the company I work for.
Hmm, strange that you can't set metadata on the PDF export.
You can set metadata, the EXIF information, also an advanced set of EXIF in Acrobat Pro. But I think that wouldn't be enough to reach your goal. So maybe scripting Acrobat Pro allows what you want, but this lies not in my realm of expertise.
Let't say I must set it on Indesign Server CC and I would like a clean API using scripting. For this discussion, the solution has to be in those limits (because I have other solutions but those would add overhead that I might not want).
From what you are saying, that is not possible or you think it's not possible.
I think it's not possible, if you are staying with the scripting DOM of inDesign. But I already hinted to the possible solution to read a file (the exported PDF), doing some edits and write that file back to disk. This of course is in the scope of the core capability of ExtendScript.
... I have to do it because it is requirement.
Please re-read where ever you got this from very, very carefully ...
Why would it ever be a "requirement" with what particular software library you created a PDF with? What advantage could it have to lie about this? (As changing the PDF Producer, a simple string, does nothing to the rest of the PDF.)
My $0.02 is that you misread an instruction somewhere and you actually have to set the regular metadata such as "Title", "Author", and "Subject". (Which can be scripted.)
Thanks for the feedback Jongware, appreciate it.
I can't speak for the product manager (I'll check with him later) on why. But I am 100% it's the PDF Producer and Creator (or Application) actually. I am looking at them on a PDF that comes from Word and goes through another flow to get PDF rendition.
I guess it's a branding thing. I was working for another content management company few years back and they had the same thing. I am certainly more of a novice with pdf and adobe stuff, but to me it would make sense to leave the Author alone, at least for my use case.
Mind you, I don't create Indesign documents, I just have to convert them (and PSD,AI) to PDF using Indesign. The request is to mark that company "xyz" produced this PDF.
Here is some more information:
1. Through the regular DOM, the class MetadataPreference allows reading and writing of 'common' PDF metadata; but "Producer" is missing from the list of supported strings. A similar item, "Creator", is present, but it is marked Read Only and returns the full name of your current InDesign.
2. The PDF object you are looking for is "/Info". This is one of the objects pointed to in the file trailer dictionary (see Table 3.13 in the PDF Reference v1.7). It is marked "optional", so you cannot be 100% sure it is actually present (although it's a fair guess it always will be there in PDFs created by InDesign).
3. The Info object contains Key-Value strings such as Author, Title, and Keywords (which can be entered in an InDesign document, and changed in Acrobat Pro) as well as document-specific values such as CreationDate, Creator, and (indeed) Producer.
4. The Info object may be compressed!
Acrobat Pro does not allow altering these fields either.
A possible solution could be http://qpdf.sourceforge.net/. This is a simple tool to convert a PDF to and from editable text.