Example





In This Topic

Repair() Method

In This Topic
Attempts to repair malformed PDF document.
Syntax
'Declaration

 

Public Overloads Function Repair() As GdPictureStatus
public GdPictureStatus Repair()
public function Repair(): GdPictureStatus; 
public function Repair() : GdPictureStatus;
public: GdPictureStatus Repair(); 
public:

GdPictureStatus Repair(); 

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.
Example
How to repair the PDF document.
Dim caption As String = "Example: Repair"

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()

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

        If gdpicturePDF.Repair() = GdPictureStatus.OK Then

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

                MessageBox.Show("The example has been followed successfully.", caption)

            Else

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

            End If

        Else

            MessageBox.Show("The error occurs when repairing document. Status: " + gdpicturePDF.GetStat().ToString(), caption)

        End If

    Else

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

    End If

End Using
string caption = "Example: Repair";

using (GdPicturePDF gdpicturePDF = new GdPicturePDF())

{

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

    {

        if (gdpicturePDF.Repair() == GdPictureStatus.OK)

        {

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

            {

                MessageBox.Show("The example has been followed successfully.", caption);

            }

            else

            {

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

            }

        }

        else

        {

            MessageBox.Show("The error occurs when repairing document. Status: " + gdpicturePDF.GetStat().ToString(), caption);

        }

    }

    else

    {

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

    }

}
See Also