Beispiel #1
0
        public PDFFileChangeSetting GetChangeSetting()
        {
            var data = new PDFFileChangeSetting();

            data.Author       = this.Author;
            data.Title        = this.Title;
            data.SubTitle     = this.SubTitle;
            data.CreationDate = this.CreationDate;
            data.Keyword      = this.Keyword;

            return(data);
        }
Beispiel #2
0
        public FileInfoChangeResult ChangeFIleInfo(string filePath, BookInfo changeInfo, PDFFileChangeSetting changeSetting)
        {
            var res = new FileInfoChangeResult();

            try
            {
                var doc = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify);

                var changeData = RenameInfo.GetReplaceParam(changeInfo);
                doc.Info.Title    = EncodingUnicode(GetChanedData(changeSetting.Title, changeData));
                doc.Info.Author   = EncodingUnicode(GetChanedData(changeSetting.Author, changeData));
                doc.Info.Keywords = EncodingUnicode(GetChanedData(changeSetting.Keyword, changeData));
                doc.Info.Subject  = EncodingUnicode(GetChanedData(changeSetting.SubTitle, changeData));
                //出版年
                var time = DateTime.Now;
                if (DateTime.TryParse(GetChanedData(changeSetting.CreationDate, changeData), out time))
                {
                    doc.Info.CreationDate = time;
                }


                doc.Save(filePath);

                res.IsSuccess = true;
            }
            catch (Exception e)
            {
                res.IsSuccess = false;
                res.Message   = e.ToString();
            }

            return(res);
        }
 public FileInfoChangeResult ChangeFIleInfo(string filePath, BookInfo changeInfo, PDFFileChangeSetting changeSetting)
 {
     if (FileUtil.IsPdfFile(filePath))
     {
         //PDFファイルのみ中身を書き換える
         return(_pdfChangeService.ChangeFIleInfo(filePath, changeInfo, changeSetting));
     }
     else
     {
         return(new FileInfoChangeResult()
         {
             IsSuccess = true, Message = String.Empty
         });
     }
 }