A bitwise combination of values of the PdfRemoveJavaScriptOptions enumeration.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / RemoveJavaScript Method

RemoveJavaScript Method (GdPicturePDF)

In This Topic
Removes all JavaScript scripts from the specified objects, that are included in the currently loaded PDF document. You can identify all required objects using the Options parameter according to your preference. Please refer to the GdPicturePDF.GetActionJavaScript method for more details.
Syntax
'Declaration

 

Public Function RemoveJavaScript( _

   ByVal Options As PdfRemoveJavaScriptOptions _

) As GdPictureStatus
public function RemoveJavaScript( 

    Options: PdfRemoveJavaScriptOptions

): GdPictureStatus; 
public function RemoveJavaScript( 

   Options : PdfRemoveJavaScriptOptions

) : GdPictureStatus;
public: GdPictureStatus RemoveJavaScript( 

   PdfRemoveJavaScriptOptions Options

) 
public:

GdPictureStatus RemoveJavaScript( 

   PdfRemoveJavaScriptOptions Options

) 

Parameters

Options
A bitwise combination of values of the PdfRemoveJavaScriptOptions enumeration.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Just to inform you, that if the currently loaded PDF document doesn't contain any JavaScript scripts, the returned value is GdPictureStatus.OK.

Example
How to remove all JavaScript scripts from the PDF document.
Dim caption As String = "Example: RemoveJavaScript"

Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()

If gdpicturePDF.LoadFromFile("javascript.pdf", False) = GdPictureStatus.OK Then

    If gdpicturePDF.RemoveJavaScript(PdfRemoveJavaScriptOptions.RemoveAllJavaScript) = GdPictureStatus.OK Then

        If gdpicturePDF.SaveToFile("javascript_removed.pdf") = GdPictureStatus.OK Then

            MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)

        Else

            MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)

        End If

    Else

        MessageBox.Show("The RemoveJavaScript() 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: RemoveJavaScript";

GdPicturePDF gdpicturePDF = new GdPicturePDF();

if (gdpicturePDF.LoadFromFile("javascript.pdf", false) == GdPictureStatus.OK)

{

    if (gdpicturePDF.RemoveJavaScript(PdfRemoveJavaScriptOptions.RemoveAllJavaScript) == GdPictureStatus.OK)

    {

        if (gdpicturePDF.SaveToFile("javascript_removed.pdf") == GdPictureStatus.OK)

            MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);

        else

            MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);

    }

    else

        MessageBox.Show("The RemoveJavaScript() 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