Accessing a document's properties/metadata

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jreljac@gmail.com

    Accessing a document's properties/metadata

    Howdy,

    Is it possible (and if it is how?) to have php display the details of a
    word/excel/pdf document's properties/metadata?

    I can go into MS Word...File...P roperties and assign things like Title,
    Subject, Author, Comments, etc... What I need to do now is put thse
    files on a server and have php display some of those properties for me.

    (Is that the same as metadata?)

    Is that possible and if it is how do I go about getting started?

    TIA,
    J-

  • Petr Vileta

    #2
    Re: Accessing a document's properties/metadata

    <jreljac@gmail. comwrote in
    news:1157503739 .848941.301680@ d34g2000cwd.goo glegroups.com.. .
    Howdy,
    >
    Is it possible (and if it is how?) to have php display the details of a
    word/excel/pdf document's properties/metadata?
    >
    I can go into MS Word...File...P roperties and assign things like Title,
    Subject, Author, Comments, etc... What I need to do now is put thse
    files on a server and have php display some of those properties for me.
    >
    (Is that the same as metadata?)
    >
    Is that possible and if it is how do I go about getting started?
    >
    This infos are near the end of DOC file. Open DOC file in some hexa-editor
    and look at the end of file. You can see something like this

    W o r d D o c u m e n t   
    ???? .$  S u m m a r y I n f o
    r m a t i o n (
    )   D o c u m e n t S u m m a r y I n f o r m a t i
    o n 8  ????????

    All texts are in unicode (UTF-16). You can open this file via PHP in binary
    mode and extract what you want :-)

    --

    Petr Vileta, Czech republic
    (My server rejects all messages from Yahoo and Hotmail. Send me your mail
    from another non-spammer site please.)


    Comment

    • Steve

      #3
      Re: Accessing a document's properties/metadata

      Is it possible (and if it is how?) to have php display the details of a
      word/excel/pdf document's properties/metadata?
      You can do this via PHPs COM support, but only if you are hosted on
      Windows with MS Office installed.

      // for MSExcel use:
      $objOfficeApp = new COM("excel.appl ication") or die("unable to
      instantiate MSExcel");
      // for MSWord use:
      //$objOfficeApp = new COM("word.appli cation") or die("unable to
      instantiate MSWord");

      $objOfficeApp->Workbooks->Open( "c:\\temp\\test .xls" );
      //$objOfficeApp->Documents->Open( "c:\\temp\\test .doc" );

      $objDocProps =
      $objOfficeApp->ActiveWorkBo ok->BuiltInDocumen tProperties();
      //$objDocProps =
      $objOfficeApp->ActiveDocume nt->BuiltInDocumen tProperties();

      $count = $objDocProps->count();

      while( $objDocProp = $objDocProps->Next() )
      {
      if( $objDocProp->Name() == 'Title' )
      {
      print 'Title: ' . $objDocProp->Value() . "\n";
      break;
      }
      }

      // *** IMPORTANT: release all resources correctly to avoid memory
      leaks...

      unset($objDocPr op);
      unset($objDocPr ops);

      $objOfficeApp->ActiveWorkBo ok->Close();
      //$objOfficeApp->ActiveDocume nt->Close();
      $objOfficeApp->Quit();
      unset($objOffic eApp);

      ---
      Steve

      Comment

      • Chung Leong

        #4
        Re: Accessing a document's properties/metadata


        jreljac@gmail.c om wrote:
        Howdy,
        >
        Is it possible (and if it is how?) to have php display the details of a
        word/excel/pdf document's properties/metadata?
        >
        I can go into MS Word...File...P roperties and assign things like Title,
        Subject, Author, Comments, etc... What I need to do now is put thse
        files on a server and have php display some of those properties for me.
        >
        (Is that the same as metadata?)
        >
        Is that possible and if it is how do I go about getting started?
        >
        TIA,
        J-
        Indexing Service is a good way to do this. See:





        Comment

        Working...