Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PdfFileInfo 类允许您设置 PDF 文件的特定信息。您需要创建一个 PdfFileInfo 类的对象,然后设置不同的文件特定属性,如作者、标题、关键字和创建者等。最后,使用 PdfFileInfo 对象的 SaveNewInfo 方法保存更新后的 PDF 文件。
以下代码片段向您展示如何设置 PDF 文件信息。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SetPdfInfo()
{
// Define the directory for input and output files
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create PdfFileInfo object to work with PDF metadata
using (var fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "sample.pdf"))
{
// Set PDF information
fileInfo.Author = "Aspose";
fileInfo.Title = "Hello World!";
fileInfo.Keywords = "Peace and Development";
fileInfo.Creator = "Aspose";
// Save the PDF with updated information
fileInfo.SaveNewInfo(dataDir + "SetFileInfo_out.pdf");
}
}
SetMetaInfo 方法允许您添加任何信息。在我们的示例中,我们添加了一个字段。请查看下一个代码片段:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SetMetaInfo()
{
// Define the directory for input and output files
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of the PdfFileInfo object
using (var fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "sample.pdf"))
{
// Set a new custom attribute as meta info
fileInfo.SetMetaInfo("Reviewer", "Aspose.PDF user");
// Save the updated file
fileInfo.SaveNewInfo(dataDir + "SetMetaInfo_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.