Search code examples
c#pdfmetadatasharepoint-2013

Edit metadata of a PDF file online with C#


I searching for methods or libarys to edit metadata of an online pdf file.

I work on Sharepoint 2013 and i have 10k files where I need to delete the "author" and "modifiedBy".

I'm on LAN and the server has no internet connection

I have already tested PDF Sharp, i can save it in local but i can't save it at the same place/url.

public static void RemoveMetadataPropertiesPdf(IGrouping<string, SPFile> GetAllSpecifiedGroupingFile)
    {
       // DeleteUserWordX();
        foreach(SPFile file in GetAllSpecifiedGroupingFile){

            Stream streamfile = file.OpenBinaryStream();

            PdfDocument document = PdfReader.Open(streamfile);

            string DocumentInfoAuto = document.Info.Author;
            document.Info.Author = "toto";
            document.Save(streamfile);
            document.Close();
            streamfile.Dispose();

            file.Update();
        }
        
    }

Maybe you have some issues or samples for c#.

Thanks a lot


Solution

  • Maybe you could use the Microsoft graph API for this, In that sense i mean importing the file with the API. Then perform your actions on the file and send it back using the API.

    Have never worked with files in the graph API, but it seems to be possible. I recommend reading the documentation well since the use of the API can be confusing

    Overview

    Microsoft Graph API

    Files

    Working with files

    Documentation

    enter link description here

    It also has an handy demo environment.