Exemplo n.º 1
0
            /// <summary>
            /// Removes custom property of Ppt file and creates output file
            /// </summary>
            public static void RemoveCustomProperties()
            {
                try
                {
                    //ExStart:RemoveCustomDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata metadata = pptFormat.DocumentProperties;

                    string propertyName = "New custom property";

                    // check if property is not built-in
                    if (!metadata.IsBuiltIn(propertyName))
                    {
                        // remove property
                        metadata.Remove(propertyName);
                    }
                    else
                    {
                        Console.WriteLine("Can not remove built-in property.");
                    }

                    // save file in destination folder
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:RemoveCustomDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Updates document properties of Ppt file and creates output file
            /// </summary>
            public static void UpdateDocumentProperties()
            {
                try
                {
                    //ExStart:UpdateBuiltinDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata pptMetadata = pptFormat.DocumentProperties;

                    // update document property
                    pptMetadata.Author  = "New author";
                    pptMetadata.Subject = "New subject";
                    pptMetadata.Manager = "Usman";

                    //save output file...
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:UpdateBuiltinDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
Exemplo n.º 3
0
            /// <summary>
            /// Gets custom properties of Ppt file
            /// </summary>
            public static void GetCustomProperties()
            {
                try
                {
                    //ExStart:GetCustomDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata pptMetadata = pptFormat.DocumentProperties;

                    Console.WriteLine("\nCustom Properties");
                    foreach (KeyValuePair <string, PropertyValue> keyValuePair in pptMetadata)
                    {
                        // check if property is not built-in
                        if (!pptMetadata.IsBuiltIn(keyValuePair.Key))
                        {
                            // get property value
                            PropertyValue propertyValue = pptMetadata[keyValuePair.Key];
                            Console.WriteLine("Key: {0}, Type:{1}, Value: {2}", keyValuePair.Key, propertyValue.Type, propertyValue);
                        }
                    }
                    //ExEnd:GetCustomDocumentPropertiesPptFormat
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
Exemplo n.º 4
0
            /// <summary>
            /// Adds custom property in Ppt file and creates output file
            /// </summary>
            public static void AddCustomProperty()
            {
                try
                {
                    //ExStart:AddCustomDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata metadata = pptFormat.DocumentProperties;

                    // set property details
                    string propertyName  = "New custom property";
                    string propertyValue = "Value";

                    // check if property already exists
                    if (!metadata.ContainsKey(propertyName))
                    {
                        // add property
                        metadata.Add(propertyName, propertyValue);
                    }

                    // save file in destination folder
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:AddCustomDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
Exemplo n.º 5
0
            //ExEnd:SourcePptFilePath
            #region working with builtin document properties
            /// <summary>
            /// Gets builtin document properties of Ppt file
            /// </summary>
            public static void GetDocumentProperties()
            {
                try
                {
                    // ExStart:GetBuiltinDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata pptMetadata = pptFormat.DocumentProperties;

                    // built-in properties
                    Console.WriteLine("\nBuilt-in Properties");
                    foreach (KeyValuePair <string, PropertyValue> property in pptMetadata)
                    {
                        if (pptMetadata.IsBuiltIn(property.Key))
                        {
                            Console.WriteLine("{0} : {1}", property.Key, property.Value);
                        }
                    }
                    //ExEnd:GetBuiltinDocumentPropertiesPptFormat
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
Exemplo n.º 6
0
            /// <summary>
            /// Removes document properties of Ppt file and creates output file
            /// </summary>
            public static void RemoveDocumentProperties()
            {
                try
                {
                    //ExStart:RemoveBuiltinDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // clean metadata
                    pptFormat.CleanMetadata();

                    // save output file...
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:RemoveBuiltinDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
            /// <summary>
            /// Removes document properties of Ppt file and creates output file
            /// </summary> 
            public static void RemoveDocumentProperties()
            {
                try
                {
                    //ExStart:RemoveBuiltinDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // clean metadata
                    pptFormat.CleanMetadata();

                    // save output file...
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:RemoveBuiltinDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");


                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
            /// <summary>
            /// Updates document properties of Ppt file and creates output file
            /// </summary> 
            public static void UpdateDocumentProperties()
            {
                try
                {
                    //ExStart:UpdateBuiltinDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata pptMetadata = pptFormat.DocumentProperties;

                    // update document property
                    pptMetadata.Author = "New author";
                    pptMetadata.Subject = "New subject";
                    pptMetadata.Manager = "Usman";

                    //save output file...
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:UpdateBuiltinDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");

                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }

            }
            //ExEnd:SourcePptFilePath
            #region working with builtin document properties
            /// <summary>
            /// Gets builtin document properties of Ppt file  
            /// </summary> 
            public static void GetDocumentProperties()
            {
                try
                {
                    // ExStart:GetBuiltinDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata pptMetadata = pptFormat.DocumentProperties;

                    // built-in properties
                    Console.WriteLine("\nBuilt-in Properties");
                    foreach (KeyValuePair<string, PropertyValue> property in pptMetadata)
                    {
                        if (pptMetadata.IsBuiltIn(property.Key))
                        {
                            Console.WriteLine("{0} : {1}", property.Key, property.Value);
                        }
                    }
                    //ExEnd:GetBuiltinDocumentPropertiesPptFormat
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
        /// <summary>
        /// Detects document protection
        /// </summary> 
        public static void DetectProtection(string filePath)
        {
            try
            {
                //ExStart:DetectProtection
                FormatBase format = FormatFactory.RecognizeFormat(Common.MapSourceFilePath(filePath));

                if (format.Type.ToString().ToLower() == "doc")
                {
                    // initialize DocFormat
                    DocFormat docFormat = new DocFormat(Common.MapSourceFilePath(filePath));

                    // determines whether document is protected by password
                    Console.WriteLine(docFormat.IsProtected ? "Document is protected" : "Document is protected");
                }
                else if (format.Type.ToString().ToLower() == "pdf")
                {
                    // initialize DocFormat
                    PdfFormat pdfFormat = new PdfFormat(Common.MapSourceFilePath(filePath));

                    // determines whether document is protected by password
                    Console.WriteLine(pdfFormat.IsProtected ? "Document is protected" : "Document is protected");
                }
                else if (format.Type.ToString().ToLower() == "xls")
                {
                    // initialize DocFormat
                    XlsFormat xlsFormat = new XlsFormat(Common.MapSourceFilePath(filePath));

                    // determines whether document is protected by password
                    Console.WriteLine(xlsFormat.IsProtected ? "Document is protected" : "Document is protected");
                }
                else if (format.Type.ToString().ToLower() == "ppt")
                {
                    // initialize DocFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // determines whether document is protected by password
                    Console.WriteLine(pptFormat.IsProtected ? "Document is protected" : "Document is protected");
                }
                else
                {
                    Console.WriteLine("Invalid Format.");
                }
                //ExEnd:DetectProtection
            }
            catch (Exception exp)
            {
                Console.WriteLine("Exception occurred: " + exp.Message);
            }

        }
            /// <summary>
            /// Removes Comments, and Hidden Slides of PowerPoint file
            /// </summary> 
            public static void RemoveHiddenData()
            {
                try
                {
                    //ExStart:RemoveHiddenDataInPPT
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // get hidden data
                    PptInspectionResult hiddenData = pptFormat.InspectDocument();

                    // get comments
                    PptComment[] comments = hiddenData.Comments;

                    if (comments.Length > 0)
                    {
                        // remove all comments
                        pptFormat.RemoveHiddenData(new PptInspectionOptions(PptInspectorOptionsEnum.Comments));
                        Console.WriteLine("Comments removed.");

                        // and commit changes
                        pptFormat.Save();
                        Console.WriteLine("Changes saved successfully!");
                    }
                    else
                    {
                        Console.WriteLine("No comments found!");
                    }
                    //ExEnd:RemoveHiddenDataInPPT

                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
            /// <summary>
            /// Gets Comments, and Hidden Slides of PowerPoint file
            /// </summary> 
            public static void GetHiddenData()
            {
                try
                {
                    //ExStart:GetHiddenDataInPPT
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // get hidden data
                    PptInspectionResult hiddenData = pptFormat.InspectDocument();

                    // get comments
                    PptComment[] comments = hiddenData.Comments;

                    // get slides
                    PptSlide[] slides = hiddenData.HiddenSlides;

                    foreach (PptComment comment in comments)
                    {
                        Console.WriteLine("Author: {0}, Slide: {1}", comment.Author, comment.SlideId);
                    }
                    //ExEnd:GetHiddenDataInPPT
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
            /// <summary>
            /// Removes custom property of Ppt file and creates output file
            /// </summary> 
            public static void RemoveCustomProperties()
            {
                try
                {
                    //ExStart:RemoveCustomDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata metadata = pptFormat.DocumentProperties;

                    string propertyName = "New custom property";

                    // check if property is not built-in
                    if (!metadata.IsBuiltIn(propertyName))
                    {
                        // remove property
                        metadata.Remove(propertyName);
                    }
                    else
                    {
                        Console.WriteLine("Can not remove built-in property.");
                    }

                    // save file in destination folder
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:RemoveCustomDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");

                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
            /// <summary>
            /// Gets custom properties of Ppt file  
            /// </summary> 
            public static void GetCustomProperties()
            {
                try
                {
                    //ExStart:GetCustomDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata pptMetadata = pptFormat.DocumentProperties;

                    Console.WriteLine("\nCustom Properties");
                    foreach (KeyValuePair<string, PropertyValue> keyValuePair in pptMetadata)
                    {
                        // check if property is not built-in
                        if (!pptMetadata.IsBuiltIn(keyValuePair.Key))
                        {
                            // get property value
                            PropertyValue propertyValue = pptMetadata[keyValuePair.Key];
                            Console.WriteLine("Key: {0}, Type:{1}, Value: {2}", keyValuePair.Key, propertyValue.Type, propertyValue);
                        }
                    }
                    //ExEnd:GetCustomDocumentPropertiesPptFormat
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
            /// <summary>
            /// Adds custom property in Ppt file and creates output file
            /// </summary> 
            public static void AddCustomProperty()
            {
                try
                {
                    //ExStart:AddCustomDocumentPropertiesPptFormat
                    // initialize PptFormat
                    PptFormat pptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // initialize PptMetadata
                    PptMetadata metadata = pptFormat.DocumentProperties;

                    // set property details 
                    string propertyName = "New custom property";
                    string propertyValue = "Value";

                    // check if property already exists
                    if (!metadata.ContainsKey(propertyName))
                    {
                        // add property
                        metadata.Add(propertyName, propertyValue);
                    }

                    // save file in destination folder
                    pptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:AddCustomDocumentPropertiesPptFormat
                    Console.WriteLine("File saved in destination folder.");


                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
        //ExEnd:ApplyLicense
        public static string CleanFile(string filePath)
        {
            try
            {
                try
                {
                    //Apply license...
                    ApplyLicense();
                }
                catch (Exception exp)
                {
                    MessageBox.Show("In Licence: " + exp.Message);
                }
                try
                {
                    //Recognize format of file...
                    FormatBase format = FormatFactory.RecognizeFormat(filePath);

                    if (format.Type.ToString().ToLower() == "doc" || format.Type.ToString().ToLower() == "docx")
                    {
                        // initialize DocFormat...
                        DocFormat docFormat = format as DocFormat;
                        if (docFormat != null)
                        {
                            // get document properties...
                            DocMetadata properties = new DocMetadata();
                            properties = docFormat.DocumentProperties;

                            //Remove custom properties...
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author        = "";
                            properties.Category      = "";
                            properties.Comments      = "";
                            properties.Company       = "";
                            properties.ContentStatus = "";
                            properties.HyperlinkBase = "";
                            properties.Keywords      = "";
                            properties.Manager       = "";
                            properties.Title         = "";

                            //Update metadata if file...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "xls" || format.Type.ToString().ToLower() == "xlsx")
                    {
                        //Initialize XlsFormat...
                        XlsFormat xlsFormat = format as XlsFormat;
                        if (xlsFormat != null)
                        {
                            //Get document properties...
                            XlsMetadata properties = xlsFormat.DocumentProperties;

                            //Remove custom properties...
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author        = "";
                            properties.Category      = "";
                            properties.Comments      = "";
                            properties.Company       = "";
                            properties.HyperlinkBase = "";
                            properties.Keywords      = "";
                            properties.Manager       = "";
                            properties.Title         = "";
                            properties.Subject       = "";

                            //Update metadata in files...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "ppt" || format.Type.ToString().ToLower() == "pptx")
                    {
                        //Initialize PptFormat...
                        PptFormat pptFormat = format as PptFormat;
                        if (pptFormat != null)
                        {
                            //Get document properties...
                            PptMetadata properties = pptFormat.DocumentProperties;

                            //Remove custom properties
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author   = "";
                            properties.Category = "";
                            properties.Comments = "";
                            properties.Company  = "";
                            properties.Keywords = "";
                            properties.Manager  = "";
                            properties.Title    = "";
                            properties.Subject  = "";

                            //Update metadata of file...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "pdf")
                    {
                        // initialize PdfFormat...
                        PdfFormat pdfFormat = format as PdfFormat;
                        if (pdfFormat != null)
                        {
                            // get document properties...
                            PdfMetadata properties = pdfFormat.DocumentProperties;

                            // Remove custom properties...
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author       = "";
                            properties.CreatedDate  = DateTime.MinValue;
                            properties.Keywords     = "";
                            properties.ModifiedDate = DateTime.MinValue;
                            properties.Subject      = "";
                            properties.TrappedFlag  = false;
                            properties.Title        = "";

                            //Update metadata of file...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "jpeg" || format.Type.ToString().ToLower() == "jpg")
                    {
                        //Get EXIF data if exists
                        ExifMetadata exifMetadata = (ExifMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.EXIF);

                        //Get XMP data if exists
                        XmpMetadata xmpMetadata = (XmpMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.XMP);
                        if (exifMetadata != null)
                        {
                            //Remove exif info...
                            ExifInfo exifInfo = exifMetadata.Data;

                            if (exifInfo.GPSData != null)
                            {
                                // set altitude, latitude and longitude to null values
                                exifInfo.GPSData.Altitude     = null;
                                exifInfo.GPSData.Latitude     = null;
                                exifInfo.GPSData.LatitudeRef  = null;
                                exifInfo.GPSData.Longitude    = null;
                                exifInfo.GPSData.LongitudeRef = null;
                            }
                            exifInfo.BodySerialNumber = "";
                            exifInfo.CameraOwnerName  = "";
                            exifInfo.CFAPattern       = new byte[] { 0 };
                        }
                        else
                        {
                            exifMetadata = new ExifMetadata();
                        }
                        try
                        {
                            //Remove XMP data...
                            XmpPacketWrapper xmpPacket = xmpMetadata.XmpPacket;
                            if (xmpPacket != null)
                            {
                                if (xmpPacket.ContainsPackage(Namespaces.DublinCore))
                                {
                                    // if not - add DublinCore schema
                                    xmpPacket.AddPackage(new DublinCorePackage());
                                    DublinCorePackage dublinCorePackage = (DublinCorePackage)xmpPacket.GetPackage(Namespaces.DublinCore);
                                    dublinCorePackage.Clear();
                                    xmpMetadata.XmpPacket = xmpPacket;
                                }
                            }
                        }
                        catch { }

                        //Update Exif info...
                        try
                        {
                            MetadataUtility.UpdateMetadata(filePath, exifMetadata);
                        }
                        catch { }

                        //Update XMP data...
                        try
                        {
                            MetadataUtility.UpdateMetadata(filePath, xmpMetadata);
                        }
                        catch { }

                        //Remove custom metadata if any...
                        MetadataUtility.CleanMetadata(filePath);

                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "png")
                    {
                        //Get XMP data...
                        XmpMetadata xmpMetadata = (XmpMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.XMP);
                        try
                        {
                            //Remove XMP metadata...
                            XmpPacketWrapper xmpPacket = xmpMetadata.XmpPacket;
                            if (xmpPacket != null)
                            {
                                if (xmpPacket.ContainsPackage(Namespaces.DublinCore))
                                {
                                    // if not - add DublinCore schema
                                    xmpPacket.AddPackage(new DublinCorePackage());
                                    DublinCorePackage dublinCorePackage = (DublinCorePackage)xmpPacket.GetPackage(Namespaces.DublinCore);
                                    dublinCorePackage.Clear();
                                    xmpMetadata.XmpPacket = xmpPacket;

                                    //Update XMP metadata in file...
                                    MetadataUtility.UpdateMetadata(filePath, xmpMetadata);

                                    //Clean custom metadata if any...
                                    MetadataUtility.CleanMetadata(filePath);
                                }
                            }
                        }
                        catch { }

                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "gif")
                    {
                        //Initialie GifFormat...
                        GifFormat gifFormat = new GifFormat(filePath);

                        //Check if Xmp supported...
                        if (gifFormat.IsSupportedXmp)
                        {
                            //Get XMP data...
                            XmpMetadata xmpMetadata = (XmpMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.XMP);
                            try
                            {
                                XmpPacketWrapper xmpPacket = xmpMetadata.XmpPacket;
                                if (xmpPacket != null)
                                {
                                    if (xmpPacket.ContainsPackage(Namespaces.DublinCore))
                                    {
                                        // if not - add DublinCore schema
                                        xmpPacket.AddPackage(new DublinCorePackage());
                                        DublinCorePackage dublinCorePackage = (DublinCorePackage)xmpPacket.GetPackage(Namespaces.DublinCore);
                                        dublinCorePackage.Clear();
                                        xmpMetadata.XmpPacket = xmpPacket;

                                        //Update Xmp data in file...
                                        MetadataUtility.UpdateMetadata(filePath, xmpMetadata);
                                        //Clean custom metadata if any...
                                        MetadataUtility.CleanMetadata(filePath);
                                    }
                                }
                            }
                            catch { }
                        }
                        return("1");
                    }
                    else
                    {
                        return("Format not supported.");
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Exception: " + exp.Message);
                    return(exp.Message);
                }
            }
            catch (Exception exp)
            {
                return(exp.Message);
            }
        }
            /// <summary>
            /// Clears custom properties of Ppt file and creates output file
            /// </summary> 
            public static void ClearCustomProperties()
            {
                try
                {
                    //ExStart:ClearCustomPropertyPptFormat
                    // initialize PptFormat
                    PptFormat PptFormat = new PptFormat(Common.MapSourceFilePath(filePath));

                    // use one of the following methods
                    // method:1 - clear custom properties
                    PptFormat.ClearCustomProperties();

                    // method:2 - clear custom properties 
                    PptFormat.DocumentProperties.ClearCustomData();

                    // save file in destination folder
                    PptFormat.Save(Common.MapDestinationFilePath(filePath));
                    //ExEnd:ClearCustomPropertyPptFormat
                    Console.WriteLine("File saved in destination folder.");

                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }