Search code examples
abcpdf

Getting the title, author, etc. of a PDF using ABCpdf


I am using ABCpdf, and simply cannot obtain the title or author of a document programmatically. Cannot seem to find any good examples on WebSupergoo's site! Must be a simple issue.

Doc d = new Doc();
d.Read(path);
var y = d.GetInfo(d.Root, "/Title:Text");
var x = d.GetInfo(d.Root, "/publicfilePath:Text");

Solution

  • OK very very simple in the end.

    This is how I am adding the information

                int theID = doc.AddObject("<< >>");
                doc.SetInfo(-1, "/Info:Ref", theID.ToString());
    
                publicPath = base.GetPublicSavePath(FilePrefix);
                doc.SetInfo(theID, "/Title:Text", "here is where the title goes");
                doc.SetInfo(theID, "/Author:Text", "WebSupergoo");
                doc.SetInfo(theID, "/publicfilePath:Text", publicPath);
    
                doc.Save(publicPath);
    

    This is how I need to obtain it

            var a = d.GetInfo(-1, "/Info/publicfilePath");
            var b = d.GetInfo(-1, "/Info/Title");