Skip to main content
Participating Frequently
April 15, 2021
Question

Pdf keywords into dynamic stamps

  • April 15, 2021
  • 2 replies
  • 1701 views

I'm trying to included a pdf's keywords in a dynamic stamp, and it just won't work.

Here is my code for that form field:

event.value=event.source.source.info.keywords;

I'm using the following to insert the file name into the stamp, and it works fine:

event.value = event.source.source.documentFileName;

Anyone have any insight?

Thanks, N

This topic has been closed for replies.

2 replies

Legend
April 16, 2021

Are these keywords accessible from doc.info.Keywords in other places (such as the JavaScript console)?

Participating Frequently
April 16, 2021
JSON.stringify(app.doc.info.Title);

...returns [document title]

JSON.stringify(app.doc.info.Keywords);

... returns ""

 

Legend
April 16, 2021

Ok, so you have shown this is not a problem with stamps, but with document.info.Keywords for this file. Thank you for sharing the file. I have now examined the file. The result is by design, but not necessarily as anyone would expect.

 

1. A PDF can contain document level metadata in two places

- the Info dictionary (old fashioned; banned in PDF 2.0)

- the embedded XMP packet (modern)

An app can set either or both; unless it is PDF 2.0 compatbible it should probably set both, and Acrobat does this. Your keyword-adding app only sets keywords in the XML packet, while it sets Title in both places.

2. The Properties dialog looks in both places for its general values. It can also be used to view the XMP directly.

3. The document.info method shows ONLY what is in the Info dictionary (and is documented to do this).

4. To fully emulate the Properties dialog you need to use both document.info and document.metadata. 

5. Getting info from the XMP is not nearly so simple as the Info dictionary!

 

Legend
April 15, 2021

In the doc it is Keywords, not keywords.

Participating Frequently
April 16, 2021

Unfortunately I tried "Keywords" as well. No luck.

Really, how freakin hard does it have to be to get keywords to display on a pdf?!

try67
Community Expert
Community Expert
April 16, 2021

Just tried it with the code above (using Keywords) and it works just fine.