GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / PageHasShape() Method
Example





In This Topic
PageHasShape() Method
In This Topic
Returns if the currently selected page of the loaded PDF contains any kind of vector content, for example paths, lines, rectangles, Bezier curves, clipping paths, etc.

A vector-based PDF uses line segments to define all of the geometry on the page. The display of the geometry remains sharp when you zoom in to see details of the drawing, and measurements and takeoffs (as well as their calibration) are more precise in a vector PDF.

Syntax
'Declaration
 
Public Function PageHasShape() As Boolean
public bool PageHasShape()
public function PageHasShape(): Boolean; 
public function PageHasShape() : boolean;
public: bool PageHasShape(); 
public:
bool PageHasShape(); 

Return Value

true if the selected page contains vector content, otherwise false. The GdPicturePDF.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 GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Example
How to find out if the current page of the PDF document contains vector content. The example shows you how to check all pages in the PDF document if they contain vector content.
Dim caption As String = "Example: PageHasShape"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("drawings.pdf", False)
If status = GdPictureStatus.OK Then
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim result As Boolean = False
        Dim pagesWithShape As Integer = 0, pagesWithoutShape As Integer = 0
        For i As Integer = 1 To pageCount
            status = gdpicturePDF.SelectPage(i)
            If status = GdPictureStatus.OK Then
                result = gdpicturePDF.PageHasShape()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    If result Then
                        pagesWithShape += 1
                        MessageBox.Show("The page nr." + i.ToString() + " HAS vector content.", caption)
                    Else
                        pagesWithoutShape += 1
                        MessageBox.Show("The page nr." + i.ToString() + " HAS NO vector content.", caption)
                    End If
                Else
                    MessageBox.Show("The PageHasShape() method has failed with the status: " + status.ToString(), caption)
                End If
            Else
                MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
            End If
        Next
        If (pagesWithShape + pagesWithoutShape) <> pageCount Then
            MessageBox.Show("Something goes wrong: " + ((pagesWithShape + pagesWithoutShape).ToString() + "!=" + pageCount.ToString()), caption)
        Else
            MessageBox.Show("Finished successfully.", caption)
        End If
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: PageHasShape";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("drawings.pdf", false);
if (status == GdPictureStatus.OK)
{
    int pageCount = gdpicturePDF.GetPageCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        bool result = false;
        int pagesWithShape = 0, pagesWithoutShape = 0;
        for (int i = 1; i <= pageCount; i++)
        {
            status = gdpicturePDF.SelectPage(i);
            if (status == GdPictureStatus.OK)
            {
                result = gdpicturePDF.PageHasShape();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    if (result)
                    {
                        pagesWithShape++;
                        MessageBox.Show("The page nr." + i.ToString() + " HAS vector content.", caption);
                    }
                    else
                    {
                        pagesWithoutShape++;
                        MessageBox.Show("The page nr." + i.ToString() + " HAS NO vector content.", caption);
                    }
                }
                else
                {
                    MessageBox.Show("The PageHasShape() method has failed with the status: " + status.ToString(), caption);
                }
            }
            else
            {
                MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
            }
        }
        if ((pagesWithShape + pagesWithoutShape) != pageCount)
        {
            MessageBox.Show("Something goes wrong: " + ((pagesWithShape + pagesWithoutShape).ToString() + "!=" + pageCount.ToString()), caption);
        }
        else
        {
            MessageBox.Show("Finished successfully.", caption);
        }
    }
    else
    {
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also