EmbeddedFiles Свойство (PdfDocument)
Возвращает или задает словарь спецификаций встроенных файлов.
Вот пример, показывающий, как получить информацию обо всех встроенных файлах PDF документа:
''' <summary>
''' Prints information about all embedded files of PDF document.
''' </summary>
''' <param name="pdfFilename">The filename of PDF document.</param>
Public Shared Sub PrintEmbeddedFilesInfo(pdfFilename As String)
' open PDF document
Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename, True)
' get the dictionary of embedded file specifications
Dim embeddedFiles As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecificationDictionary = document.EmbeddedFiles
' if dictionary is empty
If embeddedFiles Is Nothing OrElse embeddedFiles.Count = 0 Then
System.Console.WriteLine("No embedded files.")
Else
' if dictionary is NOT empty
System.Console.WriteLine(String.Format("There are {0} embedded files.", embeddedFiles.Count))
' counter of embedded files
Dim counter As Integer = 1
' for each name-specification pair
For Each embeddedFileInfo As System.Collections.Generic.KeyValuePair(Of String, Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification) In embeddedFiles
' write name of the file specification
System.Console.WriteLine(String.Format("{0}) Name: ""{1}""", System.Math.Max(System.Threading.Interlocked.Increment(counter),counter - 1), embeddedFileInfo.Key))
' get the file specification
Dim embeddedFileSpecification As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification = embeddedFileInfo.Value
' write description of the file specification
System.Console.WriteLine(String.Format(" Description: ""{0}""", embeddedFileSpecification.Description))
' write file name
System.Console.WriteLine(String.Format(" Filename: ""{0}""", embeddedFileSpecification.Filename))
' write file system
System.Console.WriteLine(String.Format(" FileSystem: ""{0}""", embeddedFileSpecification.FileSystem))
' get the embedded file
Dim embeddedFile As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile = embeddedFileSpecification.EmbeddedFile
System.Console.WriteLine(String.Format(" EmbeddedFile:"))
' write compression of the embedded file
System.Console.WriteLine(String.Format(" Compression: {0}", embeddedFile.Compression))
' write creation date of the embedded file
System.Console.WriteLine(String.Format(" CreationDate: {0}", embeddedFile.CreationDate))
' write modification date of the embedded file
System.Console.WriteLine(String.Format(" ModifyDate: {0}", embeddedFile.ModifyDate))
' write uncompressed length of the embedded file
System.Console.WriteLine(String.Format(" UncompressedLength: {0} bytes", embeddedFile.UncompressedLength))
' write compressed length of the embedded file
System.Console.WriteLine(String.Format(" CompressedLength: {0} bytes", embeddedFile.Length))
System.Console.WriteLine()
Next
End If
End Using
End Sub
/// <summary>
/// Prints information about all embedded files of PDF document.
/// </summary>
/// <param name="pdfFilename">The filename of PDF document.</param>
public static void PrintEmbeddedFilesInfo(string pdfFilename)
{
// open PDF document
using (Vintasoft.Imaging.Pdf.PdfDocument document =
new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename, true))
{
// get the dictionary of embedded file specifications
Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecificationDictionary embeddedFiles = document.EmbeddedFiles;
// if dictionary is empty
if (embeddedFiles == null || embeddedFiles.Count == 0)
{
System.Console.WriteLine("No embedded files.");
}
// if dictionary is NOT empty
else
{
System.Console.WriteLine(string.Format("There are {0} embedded files.", embeddedFiles.Count));
// counter of embedded files
int counter = 1;
// for each name-specification pair
foreach (System.Collections.Generic.KeyValuePair<string, Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification>
embeddedFileInfo in embeddedFiles)
{
// write name of the file specification
System.Console.WriteLine(string.Format("{0}) Name: \"{1}\"", counter++, embeddedFileInfo.Key));
// get the file specification
Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification embeddedFileSpecification = embeddedFileInfo.Value;
// write description of the file specification
System.Console.WriteLine(string.Format(" Description: \"{0}\"", embeddedFileSpecification.Description));
// write file name
System.Console.WriteLine(string.Format(" Filename: \"{0}\"", embeddedFileSpecification.Filename));
// write file system
System.Console.WriteLine(string.Format(" FileSystem: \"{0}\"", embeddedFileSpecification.FileSystem));
// get the embedded file
Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile embeddedFile = embeddedFileSpecification.EmbeddedFile;
System.Console.WriteLine(string.Format(" EmbeddedFile:"));
// write compression of the embedded file
System.Console.WriteLine(string.Format(" Compression: {0}", embeddedFile.Compression));
// write creation date of the embedded file
System.Console.WriteLine(string.Format(" CreationDate: {0}", embeddedFile.CreationDate));
// write modification date of the embedded file
System.Console.WriteLine(string.Format(" ModifyDate: {0}", embeddedFile.ModifyDate));
// write uncompressed length of the embedded file
System.Console.WriteLine(string.Format(" UncompressedLength: {0} bytes", embeddedFile.UncompressedLength));
// write compressed length of the embedded file
System.Console.WriteLine(string.Format(" CompressedLength: {0} bytes", embeddedFile.Length));
System.Console.WriteLine();
}
}
}
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5