在 pdf 超链接中,使用 C# .net 在运行时修改 pdf 的日期


生成

一个pdf,我正在使用aspose和下面的代码在pdf的某些文本中添加网站链接,

var link = new Aspose.Pdf.Annotations.LinkAnnotation(document.Pages[t.p], userSignRect)
{
    Action = new Aspose.Pdf.Annotations.GoToURIAction(requestHostAddress.Replace("http://", "https://") + "/document-details/" + documentId)
};

现在我想在超链接中附加pdf的修改日期运行时间。

例 : https://document-details/documentId/ModifiedDateofPdfRuntime

请帮助我/指导我如何做到这一点。

编辑:我不想要当前修改日期。使用案例 :我们已经生成了pdf,并以pdf格式提供给用户我们的基本超链接URL。(这是一个快乐的场景(

但是,如果有人正在更改我的pdf,那么我不会知道,pdf的URL仍然会路由到我的网站。

为了克服同样的问题,我想在 url 中附加 PDF 的修改日期对象,这将获取 pdf 信息并获取日期。

这样的事情,可能吗?

这应该有效。

Action = new Aspose.Pdf.Annotations.GoToURIAction(requestHostAddress
     .Replace("http://", "https://") + "/document-details/" + documentId + "_" + DateTime.Now.ToString())

我猜你正在寻找这样的东西

   DateTime creation = File.GetCreationTime(@"C:test.txt");
   DateTime modification = File.GetLastWriteTime(@"C:test.txt");

然后,您可以添加检查以检查文件是否被修改。代码是从这里复制的。

你需要使用 PdfFileInfo 类中的 ModDate 属性:

using Aspose.Pdf.Facades;
//...
var fileInfo = new PdfFileInfo(dataDir + "GetFileInfo.pdf");
var modificationDate = fileInfo.ModDate;

希望对您有所帮助。否则,请随时问我。

注意:我在Aspose担任开发人员布道者。

最新更新