NewActionNamed Method (GdPicturePDF)
 
            
                In This Topic
            
            Creates a new action of the type Named. A named action is a simple action defined by its name that PDF viewer applications are expected to support.
            See the PdfActionNamed enumeration for the predefined named actions.
            
            
            Syntax
            
        
            Parameters
- Name
 
- A member of the PdfActionNamed enumeration. Sets the destination of the action specified by its name.
 
            
            Return Value
The unique action identifier of the newly created action of the type Named. The 
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful. 
You can subsequently apply this identifier when creating actions using these methods: GdPicturePDF.SetViewerOpenAction, GdPicturePDF.SetBookmarkAction, GdPicturePDF.SetAnnotationAction or GdPicturePDF.SetFormFieldAction.
 
            
            
            
            
            
            Example
How to create a PDF document of 5 pages with 4 links on each page, while these links are associated with the predefined named actions.
            
            
            
             
    
	
		Dim failure As Boolean = True
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim actionFirstPageID As Integer = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage)
        status = gdpicturePDF.GetStat()
        Dim actionPrevPageID As Integer = -1
        If status = GdPictureStatus.OK Then
            actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage)
            status = gdpicturePDF.GetStat()
        End If
        Dim actionNextPageID As Integer = -1
        If status = GdPictureStatus.OK Then
            actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage)
            status = gdpicturePDF.GetStat()
        End If
        Dim actionLastPageID As Integer = -1
        If status = GdPictureStatus.OK Then
            actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage)
            status = gdpicturePDF.GetStat()
        End If
        If status = GdPictureStatus.OK Then
            Dim i As Integer = 0, annotID As Integer = -1
            Do
                i += 1
                failure = True
                If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.DrawText(fontResName, 1, 0.5F, "This is the page " + i.ToString()) = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") = GdPictureStatus.OK) Then
                    annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, True, 255, 0, 0)
                    status = gdpicturePDF.GetStat()
                    If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) = GdPictureStatus.OK) Then
                        annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, True, 255, 0, 0)
                        status = gdpicturePDF.GetStat()
                        If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) = GdPictureStatus.OK) Then
                            annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, True, 255, 0, 0)
                            status = gdpicturePDF.GetStat()
                            If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) = GdPictureStatus.OK) Then
                                annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, True, 255, 0, 0)
                                status = gdpicturePDF.GetStat()
                                If status = GdPictureStatus.OK Then
                                    status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID)
                                    failure = (status <> GdPictureStatus.OK)
                                End If
                            End If
                        End If
                    End If
                End If
            Loop While (Not failure) AndAlso (i < 5)
            If Not failure Then
                failure = (gdpicturePDF.SaveToFile("NamedActions.pdf") <> GdPictureStatus.OK)
            End If
        End If
    End If
End If
If failure Then
    MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionNamed")
Else
    MessageBox.Show("The example HAS been followed successfully." + vbCrLf + "The PDF document with the named actions has been created.", "Example: NewActionNamed")
End If
gdpicturePDF.Dispose()
	 
	
		bool failure = true;
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        int actionFirstPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage);
        status = gdpicturePDF.GetStat();
        int actionPrevPageID = -1;
        if (status == GdPictureStatus.OK)
        {
            actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage);
            status = gdpicturePDF.GetStat();
        }
        int actionNextPageID = -1;
        if (status == GdPictureStatus.OK)
        {
            actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage);
            status = gdpicturePDF.GetStat();
        }
        int actionLastPageID = -1;
        if (status == GdPictureStatus.OK)
        {
            actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage);
            status = gdpicturePDF.GetStat();
        }
        if (status == GdPictureStatus.OK)
        {
            int i = 0, annotID = -1;
            do
            {
                i++; failure = true;
                if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
                    (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
                    (gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
                    (gdpicturePDF.DrawText(fontResName, 1, 0.5f, "This is the page " + i.ToString()) == GdPictureStatus.OK) &&
                    (gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") == GdPictureStatus.OK) &&
                    (gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") == GdPictureStatus.OK) &&
                    (gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") == GdPictureStatus.OK) &&
                    (gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") == GdPictureStatus.OK))
                {
                    annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, true, 255, 0, 0);
                    status = gdpicturePDF.GetStat();
                    if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) == GdPictureStatus.OK))
                    {
                        annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, true, 255, 0, 0);
                        status = gdpicturePDF.GetStat();
                        if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) == GdPictureStatus.OK))
                        {
                            annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, true, 255, 0, 0);
                            status = gdpicturePDF.GetStat();
                            if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) == GdPictureStatus.OK))
                            {
                                annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, true, 255, 0, 0);
                                status = gdpicturePDF.GetStat();
                                if (status == GdPictureStatus.OK)
                                {
                                    status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID);
                                    failure = (status != GdPictureStatus.OK);
                                }
                            }
                        }
                    }
                }
            } while ((!failure) && (i < 5));
            if (!failure)
                failure = (gdpicturePDF.SaveToFile("NamedActions.pdf") != GdPictureStatus.OK);
        }
    }
}
if (failure)
    MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionNamed");
else
    MessageBox.Show("The example HAS been followed successfully.\nThe PDF document with the named actions has been created.", "Example: NewActionNamed");
gdpicturePDF.Dispose();
	 
	
 
 
            
            Example
How to create a PDF document of 5 pages with 4 links on each page, while these links are associated with the predefined named actions.
            
            Dim failure As Boolean = True
            Dim gdpicturePDF As New GdPicturePDF()
            If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
                gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
                gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
                Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
                Dim status As GdPictureStatus = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    Dim actionFirstPageID As Integer = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage)
                    status = gdpicturePDF.GetStat()
                    Dim actionPrevPageID As Integer = -1
                    If status = GdPictureStatus.OK Then
                        actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage)
                        status = gdpicturePDF.GetStat()
                    End If
                    Dim actionNextPageID As Integer = -1
                    If status = GdPictureStatus.OK Then
                        actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage)
                        status = gdpicturePDF.GetStat()
                    End If
                    Dim actionLastPageID As Integer = -1
                    If status = GdPictureStatus.OK Then
                        actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage)
                        status = gdpicturePDF.GetStat()
                    End If
                    If status = GdPictureStatus.OK Then
                        Dim i As Integer = 0, annotID As Integer = -1
                        Do
                            i += 1
                            failure = True
                            If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.DrawText(fontResName, 1, 0.5F, "This is the page " + i.ToString()) = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") = GdPictureStatus.OK) Then
                                annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, True, 255, 0, 0)
                                status = gdpicturePDF.GetStat()
                                If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) = GdPictureStatus.OK) Then
                                    annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, True, 255, 0, 0)
                                    status = gdpicturePDF.GetStat()
                                    If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) = GdPictureStatus.OK) Then
                                        annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, True, 255, 0, 0)
                                        status = gdpicturePDF.GetStat()
                                        If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) = GdPictureStatus.OK) Then
                                            annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, True, 255, 0, 0)
                                            status = gdpicturePDF.GetStat()
                                            If status = GdPictureStatus.OK Then
                                                status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID)
                                                failure = (status <> GdPictureStatus.OK)
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        Loop While (Not failure) AndAlso (i < 5)
                        If Not failure Then
                            failure = (gdpicturePDF.SaveToFile("NamedActions.pdf") <> GdPictureStatus.OK)
                        End If
                    End If
                End If
            End If
            If failure Then
                MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionNamed")
            Else
                MessageBox.Show("The example HAS been followed successfully." + vbCrLf + "The PDF document with the named actions has been created.", "Example: NewActionNamed")
            End If
            gdpicturePDF.Dispose()
            
            bool failure = true;
            GdPicturePDF gdpicturePDF = new GdPicturePDF();
            if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
            {
                gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
                gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
                string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
                GdPictureStatus status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    int actionFirstPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage);
                    status = gdpicturePDF.GetStat();
                    int actionPrevPageID = -1;
                    if (status == GdPictureStatus.OK)
                    {
                        actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage);
                        status = gdpicturePDF.GetStat();
                    }
                    int actionNextPageID = -1;
                    if (status == GdPictureStatus.OK)
                    {
                        actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage);
                        status = gdpicturePDF.GetStat();
                    }
                    int actionLastPageID = -1;
                    if (status == GdPictureStatus.OK)
                    {
                        actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage);
                        status = gdpicturePDF.GetStat();
                    }
                    if (status == GdPictureStatus.OK)
                    {
                        int i = 0, annotID = -1;
                        do
                        {
                            i++; failure = true;
                            if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
                                (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
                                (gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
                                (gdpicturePDF.DrawText(fontResName, 1, 0.5f, "This is the page " + i.ToString()) == GdPictureStatus.OK) &&
                                (gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") == GdPictureStatus.OK) &&
                                (gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") == GdPictureStatus.OK) &&
                                (gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") == GdPictureStatus.OK) &&
                                (gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") == GdPictureStatus.OK))
                            {
                                annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, true, 255, 0, 0);
                                status = gdpicturePDF.GetStat();
                                if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) == GdPictureStatus.OK))
                                {
                                    annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, true, 255, 0, 0);
                                    status = gdpicturePDF.GetStat();
                                    if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) == GdPictureStatus.OK))
                                    {
                                        annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, true, 255, 0, 0);
                                        status = gdpicturePDF.GetStat();
                                        if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) == GdPictureStatus.OK))
                                        {
                                            annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, true, 255, 0, 0);
                                            status = gdpicturePDF.GetStat();
                                            if (status == GdPictureStatus.OK)
                                            {
                                                status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID);
                                                failure = (status != GdPictureStatus.OK);
                                            }
                                        }
                                    }
                                }
                            }
                        } while ((!failure) && (i < 5));
                        if (!failure)
                            failure = (gdpicturePDF.SaveToFile("NamedActions.pdf") != GdPictureStatus.OK);
                    }
                }
            }
            if (failure)
                MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionNamed");
            else
                MessageBox.Show("The example HAS been followed successfully.\nThe PDF document with the named actions has been created.", "Example: NewActionNamed");
            gdpicturePDF.Dispose();
            
            
            
            See Also