Класс PdfEmbeddedFileSpecificationDictionary
Словарь, содержащий пары имя -
PdfEmbeddedFileSpecification.
Вот пример, показывающий, как удалить встроенный файл из PDF документа:
''' <summary>
''' Removes the embedded file from PDF document by the name of embedded file specification.
''' </summary>
''' <param name="pdfFilename">The filename of PDF document.</param>
''' <param name="embeddedFileName">Name of the embedded file specification.</param>
''' <returns><b>true</b> if the file is found and successfully removed; otherwise, <b>false</b>.</returns>
Public Shared Function RemoveEmbeddedFileFromPdfDocument(pdfFilename As String, embeddedFileName As String) As Boolean
' open PDF document
Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
' if embedded files are absent
If document.EmbeddedFiles Is Nothing OrElse document.EmbeddedFiles.Count = 0 Then
Return False
End If
' try to remove embedded file specification
If Not document.EmbeddedFiles.Remove(embeddedFileName) Then
Return False
End If
' save changes to the source
document.SaveChanges()
Return True
End Using
End Function
/// <summary>
/// Removes the embedded file from PDF document by the name of embedded file specification.
/// </summary>
/// <param name="pdfFilename">The filename of PDF document.</param>
/// <param name="embeddedFileName">Name of the embedded file specification.</param>
/// <returns><b>true</b> if the file is found and successfully removed; otherwise, <b>false</b>.</returns>
public static bool RemoveEmbeddedFileFromPdfDocument(string pdfFilename, string embeddedFileName)
{
// open PDF document
using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
{
// if embedded files are absent
if (document.EmbeddedFiles == null || document.EmbeddedFiles.Count == 0)
return false;
// try to remove embedded file specification
if (!document.EmbeddedFiles.Remove(embeddedFileName))
return false;
// save changes to the source
document.SaveChanges();
return true;
}
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5