Dim caption As String = "Example: RemoveUnusedResources"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
        Dim pageCount As Integer = gdpicturePDF.GetPageCount()
        If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.GetPageCount() > 2) Then
            'Removing some pages.
            If (gdpicturePDF.DeletePage(pageCount) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.DeletePage(1) = GdPictureStatus.OK) Then
                If gdpicturePDF.RemoveUnusedResources() = GdPictureStatus.OK Then
                    If gdpicturePDF.SaveToFile("test_optimized.pdf", True) = 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 reducing resources. Status: " + gdpicturePDF.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("No pages have been removed, the example has not been followed. 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: RemoveUnusedResources";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
    {
        int pageCount = gdpicturePDF.GetPageCount();
        if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
            (gdpicturePDF.GetPageCount() > 2))
        {
            //Removing some pages.
            if ((gdpicturePDF.DeletePage(pageCount) == GdPictureStatus.OK) &&
                (gdpicturePDF.DeletePage(1) == GdPictureStatus.OK))
            {
                if (gdpicturePDF.RemoveUnusedResources() == GdPictureStatus.OK)
                {
                    if (gdpicturePDF.SaveToFile("test_optimized.pdf", true) == 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 reducing resources. Status: " + gdpicturePDF.GetStat().ToString(), caption);
            }
            else
                MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}