GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / HasJavaScript Method
Example





In This Topic
HasJavaScript Method (GdPicturePDF)
In This Topic
Returns if the currently loaded PDF document contains any executable JavaScript actions.
Syntax
'Declaration
 
Public Function HasJavaScript() As Boolean
public bool HasJavaScript()
public function HasJavaScript(): Boolean; 
public function HasJavaScript() : boolean;
public: bool HasJavaScript(); 
public:
bool HasJavaScript(); 

Return Value

true if the currently loaded PDF document contains any JavaScript actions, otherwise false. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

Example
How to find out if the PDF document contains JavaScript actions.
Dim caption As String = "Example: HasJavaScript"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("sample.pdf", False) = GdPictureStatus.OK Then
    Dim hasJS As Boolean = gdpicturePDF.HasJavaScript()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If hasJS Then
            MessageBox.Show("This PDF document contains JavaScript.", caption)
        Else
            MessageBox.Show("This PDF document contains NO JavaScript.", caption)
        End If
    Else
        MessageBox.Show("The HasJavaScript() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: HasJavaScript";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("sample.pdf", false) == GdPictureStatus.OK)
{
    bool hasJS = gdpicturePDF.HasJavaScript();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if (hasJS)
            MessageBox.Show("This PDF document contains JavaScript.", caption);
        else
            MessageBox.Show("This PDF document contains NO JavaScript.", caption);
    }
    else
        MessageBox.Show("The HasJavaScript() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
See Also