PDF metadata

Can anyone help with the Opus metadata field names for PDFs (Document properties, presumably).

What is the appropriate field name for Comment in the metadata panel? the documentation suggests "Comments ", but using it programmatically will not extract the data.

What is the appropriate field name for Authors? Or is this like tags, where you have to pull them out using a different method?

If you work out which file display column shows the data you want, that's usually the best way.

The scripting metadata objects map on to the columns in the file display.

You can find the programmatic names for a column via scripts, or (what I usually use) the Command Editor (toolbar button editor) arguments menu for the Set command:


They're also in the manual.

Obviously I did look in the manual which says the metadata field for comment in documents is called comments

I only queried when I discovered it does not seem to work:

Dim selItem, title, subject, author, comments For Each selItem in clickData.func.sourcetab.selected Set imageData = selItem.Metadata.doc title = imageData.title subject = imageData.subject author = imageData.author comments = imageData.comments taggery = imagedata.tags msgbox comments Next dlg.control("subject").value = subject dlg.control("comment").value = comments dlg.control("photog").value = author dlg.Control("title").value = title Do Set msg = dlg.GetMsg() Loop While msg

The snippet of code extracts the value from certain metadata fields of PDF files. Everyone works fine apart from comments. The message box is always empty. Maybe I am doing something stupid, it would not be the first time, but it is difficult to see what given that the construct for the comments item is identical to the others.

Add columns to the file display until you find the one with the detail you're looking for.

I did as you suggested, Leo.

As per the documentation, the field is called Comments. However, when I had that column to the Lister, lo and behold it is empty for every PDF file But the the metadata panel indicates many have content in the comments field. I then added the author column to the Lister. All is fine with this column.

This bears out what I have discovered with my VB code in the comment field in PDFs does not seem to work. There does seem to be an anomaly here.

It may not be in the column you expect. Try adding other columns. (Add all of them if you have to!)

That's exactly what I would do, but it's best if you do it as then you know it definitely works with your PDF file and the way it is tagged.

Eventually I found that by adding the Description column from the general metadata I could get the value of the comments in the PDF into my Lister.

My question now is how to I access the description field when I am using

Set imageData = selItem.Metadata.doc

Description is a combination of other columns and could also show things you don't want.

User Description (userdesc) might be the one you want, and doesn't include the extra stuff. See if that shows the right information for your file in the file display.

userdesc works fine to show the PDF comments in a Lister column

as I am using

Set imageData = selItem.Metadata.doc

to extract the fields from the pdf metadata, it does not extract the data in the VB program, presumably because userdesc is not a doc metadata field???

How can I get round this?

OtherMeta looks like it has what you need in usercomment (there's also autodesc which is what's in the Description field, but I don't think you want that except as a last resort).

Thanks for your help so far which has helped me understand what is going on with PDF meta data.

The problem I face is that to extract the metadata from PDFs I have to address both the .doc and the .other (I need to address this to get the tags and comment fields.

This where I am stuck and need some help. This is a snippet of VB code I am using at present

[code]Function OnClick(ByRef clickData)
Set dlg = clickData.func.Dlg ' Better than DOpus.Dlg if running from a button
' dlg.window = clickData.func.sourcetab ' Not needed if using clickData.func.dlg
dlg.template = "rogpdf"
dlg.detach = true
'dlg.Show
retval =Dlg.Show
if retval = "0" Then
Exit Function
End If
Dim selItem, title, subject, author, comments, taggery
For Each selItem in clickData.func.sourcetab.selected
Function OnClick(ByRef clickData)
Set dlg = clickData.func.Dlg ' Better than DOpus.Dlg if running from a button
' dlg.window = clickData.func.sourcetab ' Not needed if using clickData.func.dlg
dlg.template = "rogpdf"
dlg.detach = true
'dlg.Show
retval =Dlg.Show
if retval = "0" Then
Exit Function
End If
Dim selItem, title, subject, author, comments, taggery
For Each selItem in clickData.func.sourcetab.selected
Set imageData = selItem.Metadata.doc
title = imageData.title
subject = imageData.subject
author = imageData.author
taggery = imagedata.tags

Next
dlg.control("subject").value = subject
dlg.control("comment").value = comments
dlg.control("photog").value = author
dlg.Control("title").value = title
dlg.Control("keyword").value = tags
Do
Set msg = dlg.GetMsg()
Loop While msg
title = imageData.title
subject = imageData.subject
author = imageData.author
taggery = imagedata.tags

Next
dlg.control("subject").value = subject
dlg.control("comment").value = comments
dlg.control("photog").value = author
dlg.Control("title").value = title
dlg.Control("keyword").value = tags
Do
Set msg = dlg.GetMsg()
Loop While msg[/code]

what I cannot understand how to do is to address the .doc and .other parts of the

Set imageData = selItem.Metadata.doc

I will never extract the tags (taggery = imagedata.tags ) as it belongs in Metadata.other

Tags are actually in the Metadata object itself, not one of its sub-objects. You can get them directly with Metadata.tags.

Thanks for the info Jon.

As you can readily see I am not vb expert, and am finding it a fascinating if frustrating experience getting to grips with it.

I cannot work out how to use the metadata.tags.

For instance if I wished to extract the Title from a picture or document, how exactly would I write the code? It is the syntax of the command that frustrates me all the time.

Many thanks for your patience.

"Tags" is an overloaded term and I think it is causing a lot of the confusion here.

Metadata.tags is just a list of strings, used like keywords. Any string at all can be added to that list. Whatever you type can be added to the list. Metadata.tags just returns the list of strings which have been typed.

Metadata.tags is not any specific name/value fields. It is not for things like "Author: JK Rowling" or "Artist: David Hasselhoff".

In terms of the Metadata panel, Metadata.tags is just the one line with the red triangle next to it in this screenshot:


Metadata.tags is not any of these other lines:


If you want the document Title, that will not be in Metadata.tags. The way to get specific name/value fields was shown in Re: Gathering image metadata for things that are part of Metadata.image, and it's the same for things that are part of Metadata.doc and Metadata.other.

You're already using similar code in some of your examples above. The only problem seems to be this question:

If you want to use both, you simply use both. Nothing is stopping you:

Option Explicit Function OnClick(ByRef clickData) Dim selItem, imageData For Each selItem in clickData.func.sourcetab.selected ' Do Anything you want with selItem.Metadata.doc here ' Do Anything you want with selItem.Metadata.other here Next End Function

If you want, you can do something like this to make things a bit tidier (and possibly more efficient), but the end result is the same as above:

Option Explicit Function OnClick(ByRef clickData) Dim selItem, imageData For Each selItem in clickData.func.sourcetab.selected Set metaData = selItem.Metadata Set docData = metaData.doc Set otherData = metaData.other ' Do Anything you want with docData here ' Do Anything you want with otherData here Next End Function

Here I am, back like a bad penny.

Thanks for your advice. I followed it with the code

For Each selItem in clickData.func.sourcetab.selected Set metaData = selItem.Metadata Set docData = metaData.doc Set otherData = metaData.other ' Do Anything you want with docData here title = docdata.title subject = docdata.subject author = docdata.author ' Do Anything you want with otherData here comments = otherdata.comment

It works a dream until I get to the nightmare of otherdata.comment.

All the other extractions work fine, but the comment variable is always empty. However ig i insert the column User Description into a Lister, I can see the PDF comments fine.

This I really cannot fathom. Any ideas?

BTW: I have tried the other metadata types like image and even music to no avail.

The property is called OtherMeta.usercomment, not comment.

Thanks so much Jon.

In the help file on Opus 12 the keyword is listed as comment. It might be helpful to change that to usercomment?

It says usercomment on the page I linked to earlier: