How to read out internal pdf creation/modified date with Windows PowerShell


PDF files seem to have a separate set of file properties which contain (among others) a creation date and a modified date (see screenshot here:×297.png).

Those date obviously can differ from the creation and modified date shown in the file system (Windows Explorer).

How can I access the date information in the PDF file and read it out in Windows 7 with Windows PowerShell (or maybe another method)?

Best Answer

You can read a PDF file (at least you can in newer formats) as though it were text. You will find an embedded XML section that uses the Adobe XMP schema. This contains the metadata you need.

Here is an example:

2 0 obj
/AcroForm 4 0 R
/Lang (en-GB)
/MarkInfo <<
/Marked true
/Metadata 5 0 R
/Pages 6 0 R
/StructTreeRoot 7 0 R
/Type /Catalog
5 0 obj
/Length 2971
/Subtype /XML
/Type /Metadata
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.1.2">
    <rdf:RDF xmlns:rdf="">
        <rdf:Description rdf:about=""
        <rdf:Description rdf:about=""
        <rdf:Description rdf:about=""

The following example will retrieve the create date:

$a = Select-String "CreateDate\>(.*)\<" .\filename.pdf

Which returns something like:

filename.pdf:20:         <xap:CreateDate>2009-11-03T10:54:29Z</xap:CreateDate>
filename.pdf:12921:         <xap:CreateDate>2009-11-03T10:54:29Z</xap:CreateDate>

Getting to the exact data:


Which returns:

Related Question