VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Pdf.Tree Namespace / PdfEmbeddedFileSpecificationDictionary Class
Members Example



In This Topic
    PdfEmbeddedFileSpecificationDictionary Class
    In This Topic
    The dictionary that contains name - PdfEmbeddedFileSpecification pairs.
    Object Model
    PdfEmbeddedFileSpecificationDictionary ClassPdfEmbeddedFileSpecification Class
    Syntax
    'Declaration
     
    Public Class PdfEmbeddedFileSpecificationDictionary 
       Inherits Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionaryBase(Of PdfEmbeddedFileSpecification)
    public class PdfEmbeddedFileSpecificationDictionary : Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionaryBase<PdfEmbeddedFileSpecification> 
    public __gc class PdfEmbeddedFileSpecificationDictionary : public Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionaryBase<PdfEmbeddedFileSpecification> 
    public ref class PdfEmbeddedFileSpecificationDictionary : public Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionaryBase<PdfEmbeddedFileSpecification> 
    Example
    This example 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

    System.Object
       Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
          Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionaryBase<T>
             Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecificationDictionary

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also