VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfEmbeddedGotoAction Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    PdfEmbeddedGotoAction Class
    In This Topic
    Defines a go-to action that allows jumping to or from a PDF file that is embedded in another PDF file.
    Object Model
    PdfFileSpecification PdfEmbeddedGotoActionTarget PdfDestinationBase PdfDocument PdfIndirectReference PdfBasicObject PdfEmbeddedGotoAction
    Syntax
    'Declaration
    
    Public Class PdfEmbeddedGotoAction
       Inherits PdfGotoActionBase
    
    
    public class PdfEmbeddedGotoAction : PdfGotoActionBase
    
    
    public __gc class PdfEmbeddedGotoAction : public PdfGotoActionBase*
    
    
    public ref class PdfEmbeddedGotoAction : public PdfGotoActionBase^
    
    
    Example

    Here is an example that shows how to add the embedded PDF document to specified PDF document and create bookmark with link to embedded PDF document.

    
    ''' <summary>
    ''' Adds the embedded PDF document to the specified PDF document and creates bookmark with link to the embedded PDF document.
    ''' </summary>
    ''' <param name="sourceDocumentFilename">The filename of source PDF document.</param>
    ''' <param name="embeddingDocumentFilename">The filename of PDF document that should be embedded.</param>
    Public Shared Sub AddEmbeddedDocument(sourceDocumentFilename As String, embeddingDocumentFilename As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(sourceDocumentFilename)
            ' if document does not have embedded files
            If document.EmbeddedFiles Is Nothing Then
                ' create EmbeddedFiles dictionary
                document.EmbeddedFiles = New Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecificationDictionary(document)
            End If
    
            ' name of embedded document
            Dim embeddedDocumentName As String = System.IO.Path.GetFileName(embeddingDocumentFilename)
    
            ' create embedded file, use ZIP compression
            Dim embeddedFile As New Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile(document, embeddingDocumentFilename, Vintasoft.Imaging.Pdf.PdfCompression.Zip)
    
            ' add embedded file to EmbeddedFiles
            document.EmbeddedFiles.Add(embeddedDocumentName, New Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification(System.IO.Path.GetFileName(embeddingDocumentFilename), embeddedFile))
    
            ' if document does not have bookmarks
            If document.Bookmarks Is Nothing Then
                ' create document bookmarks
                document.Bookmarks = New Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection(document)
            End If
    
            ' create destination to the first page of document
            Dim destination As Vintasoft.Imaging.Pdf.Tree.PdfDestinationBase = New Vintasoft.Imaging.Pdf.Tree.PdfDestinationFit(document, 0)
            ' create target that goes to the embedded PDF document
            Dim actionTarget As New Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoActionTarget(document, embeddedDocumentName)
            ' create embedded action that opens the first page in embedded PDF document
            Dim action As New Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoAction(destination, actionTarget)
    
            ' create bookmark
            Dim bookmark As New Vintasoft.Imaging.Pdf.Tree.PdfBookmark(document)
            ' set the bookmark title
            bookmark.Title = embeddedDocumentName
            ' set the bookmark action
            bookmark.Action = action
            ' add bookmark to the document bookmarks
            document.Bookmarks.Add(bookmark)
    
            ' save changes in PDF document
            document.SaveChanges()
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Adds the embedded PDF document to the specified PDF document and creates bookmark with link to the embedded PDF document.
    /// </summary>
    /// <param name="sourceDocumentFilename">The filename of source PDF document.</param>
    /// <param name="embeddingDocumentFilename">The filename of PDF document that should be embedded.</param>
    public static void AddEmbeddedDocument(string sourceDocumentFilename, string embeddingDocumentFilename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(sourceDocumentFilename))
        {
            // if document does not have embedded files
            if (document.EmbeddedFiles == null)
                // create EmbeddedFiles dictionary
                document.EmbeddedFiles = new Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecificationDictionary(document);
    
            // name of embedded document
            string embeddedDocumentName = System.IO.Path.GetFileName(embeddingDocumentFilename);
    
            // create embedded file, use ZIP compression
            Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile embeddedFile =
                new Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile(document, embeddingDocumentFilename, Vintasoft.Imaging.Pdf.PdfCompression.Zip);
    
            // add embedded file to EmbeddedFiles
            document.EmbeddedFiles.Add(
                embeddedDocumentName,
                new Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification(System.IO.Path.GetFileName(embeddingDocumentFilename), embeddedFile));
    
            // if document does not have bookmarks
            if (document.Bookmarks == null)
                // create document bookmarks
                document.Bookmarks = new Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection(document);
    
            // create destination to the first page of document
            Vintasoft.Imaging.Pdf.Tree.PdfDestinationBase destination =
                new Vintasoft.Imaging.Pdf.Tree.PdfDestinationFit(document, 0);
            // create target that goes to the embedded PDF document
            Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoActionTarget actionTarget =
                new Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoActionTarget(document, embeddedDocumentName);
            // create embedded action that opens the first page in embedded PDF document
            Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoAction action =
                new Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoAction(destination, actionTarget);
    
            // create bookmark
            Vintasoft.Imaging.Pdf.Tree.PdfBookmark bookmark = new Vintasoft.Imaging.Pdf.Tree.PdfBookmark(document);
            // set the bookmark title
            bookmark.Title = embeddedDocumentName;
            // set the bookmark action
            bookmark.Action = action;
            // add bookmark to the document bookmarks
            document.Bookmarks.Add(bookmark);
    
            // save changes in PDF document
            document.SaveChanges();
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
          Vintasoft.Imaging.Pdf.Tree.PdfAction
             Vintasoft.Imaging.Pdf.Tree.PdfGotoActionBase
                Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedGotoAction

    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