/* Antenna House PDF Tool API V8.0 .NET Interface sample program 概要:文書情報の取得 Copyright 2013-2025 Antenna House, Inc. */ using System; using PdfTkNet; namespace GetDocInfo { class Program { static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("usage: GetDocInfo.exe in-pdf-file"); return; } try { using (PtlParamInput inputFile = new PtlParamInput(args[0])) using (PtlPDFDocument doc = new PtlPDFDocument()) { //PDFファイルをロードします。 doc.load(inputFile); //PDFの文書プロパティ using (PtlDocProperty docproperty = doc.getDocProperty()) { //PDFの文書情報 using (PtlDocInfo docinf = docproperty.getDocInfo()) { //タイトル取得 Console.WriteLine("Title : " + docinf.getTitle()); //著者取得 Console.WriteLine("Author : " + docinf.getAuthor()); //サブジェクト取得 Console.WriteLine("Subject : " + docinf.getSubject()); //キーワード取得 Console.WriteLine("Keywords : " + docinf.getKeywords()); //クリエータ取得 Console.WriteLine("Creator : " + docinf.getCreator()); //プロデューサ取得 Console.WriteLine("Producer : " + docinf.getProducer()); //作成日付を取得 using (PtlDate date = docinf.getCreationDate()) { int year = date.getYear(); int month = date.getMonth(); int day = date.getDay(); int hour = date.getHour(); int min = date.getMin(); int sec = date.getSec(); Console.WriteLine("CreationDate : {0}/{1}/{2} {3}:{4}:{5}", year, month, day, hour, min, sec); } //更新日付を取得 using (PtlDate date = docinf.getModDate()) { int year = date.getYear(); int month = date.getMonth(); int day = date.getDay(); int hour = date.getHour(); int min = date.getMin(); int sec = date.getSec(); Console.WriteLine("ModDate : {0}/{1}/{2} {3}:{4}:{5}", year, month, day, hour, min, sec); } } } } } catch (PtlException pex) { Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP()); pex.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("-- 完了 --"); } } } }