VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfEmbeddedFileSpecificationDictionary Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    PdfEmbeddedFileSpecificationDictionary Class
    In This Topic
    The dictionary that contains name - PdfEmbeddedFileSpecification pairs.
    Object Model
    PdfEmbeddedFileSpecification PdfDocument PdfIndirectReference PdfBasicObject PdfEmbeddedFileSpecificationDictionary
    Syntax
    'Declaration
    
    <DefaultMemberAttribute("Item")>
    Public Class PdfEmbeddedFileSpecificationDictionary
       Inherits PdfNamedDictionaryBase(Of T)
    
    
    [DefaultMember("Item")]
    public class PdfEmbeddedFileSpecificationDictionary : PdfNamedDictionaryBase<T>
    
    
    [DefaultMember("Item")]
    public __gc class PdfEmbeddedFileSpecificationDictionary : public PdfNamedDictionaryBase<T*>*
    
    
    [DefaultMember("Item")]
    public ref class PdfEmbeddedFileSpecificationDictionary : public PdfNamedDictionaryBase<T^>^
    
    
    Example

    Here is an example that shows how to remove an embedded file from PDF document:

    
    ''' <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;
        }
    }
    
    

    Inheritance Hierarchy
    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also