Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PDF 파일의 특정 정보를 얻으려면 PdfFileInfo 클래스의 객체를 생성해야 합니다. 그 후, 주제, 제목, 키워드 및 작성자와 같은 개별 속성의 값을 가져올 수 있습니다.
다음 코드 스니펫은 PDF 파일 정보를 가져오는 방법을 보여줍니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetPdfInfo()
{
// Define the directory for input files
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "sample.pdf"))
{
// Get and display PDF information
Console.WriteLine("Subject: {0}", fileInfo.Subject);
Console.WriteLine("Title: {0}", fileInfo.Title);
Console.WriteLine("Keywords: {0}", fileInfo.Keywords);
Console.WriteLine("Creator: {0}", fileInfo.Creator);
Console.WriteLine("Creation Date: {0}", fileInfo.CreationDate);
Console.WriteLine("Modification Date: {0}", fileInfo.ModDate);
// Check if the file is a valid PDF and if it is encrypted
Console.WriteLine("Is Valid PDF: {0}", fileInfo.IsPdfFile);
Console.WriteLine("Is Encrypted: {0}", fileInfo.IsEncrypted);
// Get dimensions of the first page
Console.WriteLine("Page width: {0}", fileInfo.GetPageWidth(1));
Console.WriteLine("Page height: {0}", fileInfo.GetPageHeight(1));
}
}
정보를 얻기 위해 Header 속성을 사용합니다. ‘Hashtable’을 사용하여 가능한 모든 값을 가져옵니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetMetaInfo()
{
// Define the directory for input files
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of PdfFileInfo object
using (var fileInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "SetMetaInfo_out.pdf"))
{
// Retrieve all existing custom attributes
var hashTable = new System.Collections.Hashtable(fileInfo.Header);
// Enumerate and display all custom attributes
var enumerator = hashTable.GetEnumerator();
while (enumerator.MoveNext())
{
string output = $"{enumerator.Key} {enumerator.Value}";
Console.WriteLine(output);
}
// Retrieve and display a specific custom attribute
Console.WriteLine("Reviewer: " + fileInfo.GetMetaInfo("Reviewer"));
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.