简体   繁体   English

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

[英]In pdf hyperlink modify date of pdf at runtime using C# .net

One pdf is generated and I am adding link of website in some text of pdf using aspose and below code, 生成一个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)
};

Now I want to append pdf's modified date run time in hyperlink. 现在我想在超链接中附加pdf的修改日期运行时间。

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

Please help me/guide me how to do that. 请帮助我/指导我如何做到这一点。

Edit: I do not want current modified date. 编辑:我不想要当前修改日期。 Usecase : We have generated pdf and given to user with our basic hyperlink url in pdf.(which is a happy scenario) 用例:我们生成了pdf并通过PDF格式的基本超链接URL提供给用户(这是一个快乐的场景)

But if someone is altering my pdf then i won't know and pdf's url will still route to my website. 但如果有人正在改变我的PDF格式,那么我将不知道,pdf的网址仍将路由到我的网站。

To overcome same i want to append PDF's modified date object in url which will fetch pdf info and get date. 为了克服这一点,我想在url中附加PDF的修改日期对象,它将获取pdf信息并获取日期。

something like this, is it possible ? 这样的事情,有可能吗?

I guess you are looking for something like this 我想你正在寻找这样的东西

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

and then you can add checks to check if file is modified or not. 然后您可以添加检查以检查文件是否被修改。 code is copied from here . 代码是从这里复制的。

This should work. 这应该工作。

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

You need to use ModDate property from PdfFileInfo class: 您需要使用PdfFileInfo类中的ModDate属性:

using Aspose.Pdf.Facades;

//...

var fileInfo = new PdfFileInfo(dataDir + "GetFileInfo.pdf");
var modificationDate = fileInfo.ModDate;

Hope it helps. 希望能帮助到你。 Otherwise, feel free to ask me. 否则,请随时问我。

Note : I am working as Developer Evangelist at Aspose. 注意 :我在Aspose担任开发人员传播者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM