Example #1
0
        private void ChangeProp(string file, string author)
        {
            DSOFile.OleDocumentPropertiesClass documentProperties = new DSOFile.OleDocumentPropertiesClass();
            DSOFile.SummaryProperties          summaryProperties;


            try
            {
                documentProperties.Open(file, false, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
                documentProperties.Save();
            }
            finally
            {
                summaryProperties  = null;
                documentProperties = null;
            }
        }
        public static MetaDataItem[] GetFromOLEDocument(string filename)
        {
            List <MetaDataItem> ret = new List <MetaDataItem>();

            if (CanExtractOLEMetaData(filename))
            {
                try
                {
#if !MONO
                    if (!PageUtils.IsRunningOnMono())
                    {
                        DSOFile.OleDocumentPropertiesClass propClass = new DSOFile.OleDocumentPropertiesClass();

                        propClass.Open(filename, true, DSOFile.dsoFileOpenOptions.dsoOptionDontAutoCreate | DSOFile.dsoFileOpenOptions.dsoOptionOnlyOpenOLEFiles);

                        if (propClass.SummaryProperties.ApplicationName != null)
                        {
                            ret.Add(new MetaDataItem("OLE:ApplicationName", propClass.SummaryProperties.ApplicationName));
                        }

                        if (propClass.SummaryProperties.Author != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Author", propClass.SummaryProperties.Author));
                        }
                        if (propClass.SummaryProperties.ByteCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:ByteCount", propClass.SummaryProperties.ByteCount));
                        }
                        if (propClass.SummaryProperties.Category != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Category", propClass.SummaryProperties.Category));
                        }
                        if (propClass.SummaryProperties.CharacterCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:CharacterCount", propClass.SummaryProperties.CharacterCount));
                        }
                        if (propClass.SummaryProperties.CharacterCountWithSpaces > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:CharacterCountWithSpaces", propClass.SummaryProperties.CharacterCountWithSpaces));
                        }
                        if (propClass.SummaryProperties.Comments != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Comments", propClass.SummaryProperties.Comments));
                        }
                        if (propClass.SummaryProperties.Company != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Company", propClass.SummaryProperties.Company));
                        }
                        if (propClass.SummaryProperties.DateCreated != null)
                        {
                            ret.Add(new MetaDataItem("OLE:DateCreated", Convert.ToDateTime(propClass.SummaryProperties.DateCreated)));
                        }
                        if (propClass.SummaryProperties.DateLastPrinted != null)
                        {
                            ret.Add(new MetaDataItem("OLE:DateLastPrinted", Convert.ToDateTime(propClass.SummaryProperties.DateLastPrinted)));
                        }
                        if (propClass.SummaryProperties.DateLastSaved != null)
                        {
                            ret.Add(new MetaDataItem("OLE:DateLastSaved", Convert.ToDateTime(propClass.SummaryProperties.DateLastSaved)));
                        }

                        /*
                         * if(propClass.SummaryProperties.DigitalSignature != null)
                         *  ret.Add(new MetaDataItem("OLE:DigitalSignature", propClass.SummaryProperties.DigitalSignature));*/
                        if (propClass.SummaryProperties.HiddenSlideCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:HiddenSlideCount", propClass.SummaryProperties.HiddenSlideCount));
                        }
                        if (propClass.SummaryProperties.Keywords != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Keywords", propClass.SummaryProperties.Keywords));
                        }
                        if (propClass.SummaryProperties.LastSavedBy != null)
                        {
                            ret.Add(new MetaDataItem("OLE:LastSavedBy", propClass.SummaryProperties.LastSavedBy));
                        }
                        if (propClass.SummaryProperties.LineCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:LineCount", propClass.SummaryProperties.LineCount));
                        }
                        if (propClass.SummaryProperties.Manager != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Manager", propClass.SummaryProperties.Manager));
                        }
                        if (propClass.SummaryProperties.MultimediaClipCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:MultimediaClipCount", propClass.SummaryProperties.MultimediaClipCount));
                        }
                        if (propClass.SummaryProperties.NoteCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:NoteCount", propClass.SummaryProperties.NoteCount));
                        }
                        if (propClass.SummaryProperties.PageCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:PageCount", propClass.SummaryProperties.PageCount));
                        }
                        if (propClass.SummaryProperties.ParagraphCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:ParagraphCount", propClass.SummaryProperties.ParagraphCount));
                        }
                        if (propClass.SummaryProperties.PresentationFormat != null)
                        {
                            ret.Add(new MetaDataItem("OLE:PresentationFormat", propClass.SummaryProperties.PresentationFormat));
                        }
                        if (propClass.SummaryProperties.RevisionNumber != null)
                        {
                            ret.Add(new MetaDataItem("OLE:RevisionNumber", propClass.SummaryProperties.RevisionNumber));
                        }

                        /*
                         * if(propClass.SummaryProperties.SharedDocument != null)
                         *  ret.Add(new MetaDataItem("OLE:SharedDocument", propClass.SummaryProperties.SharedDocument)); */
                        if (propClass.SummaryProperties.SlideCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:SlideCount", propClass.SummaryProperties.SlideCount));
                        }
                        if (propClass.SummaryProperties.Subject != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Subject", propClass.SummaryProperties.Subject));
                        }
                        if (propClass.SummaryProperties.Template != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Template", propClass.SummaryProperties.Template));
                        }
                        if (propClass.SummaryProperties.Title != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Title", propClass.SummaryProperties.Title));
                        }
                        if (propClass.SummaryProperties.TotalEditTime > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:TotalEditTime", propClass.SummaryProperties.TotalEditTime));
                        }
                        if (propClass.SummaryProperties.Version != null)
                        {
                            ret.Add(new MetaDataItem("OLE:Version", propClass.SummaryProperties.Version));
                        }
                        if (propClass.SummaryProperties.WordCount > 0)
                        {
                            ret.Add(new MetaDataItem("OLE:WordCount", propClass.SummaryProperties.WordCount));
                        }
                    } // if
#endif
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            } // if
            return(ret.ToArray());
        }