GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / PdfGetPageHeight Method
Example





In This Topic
PdfGetPageHeight Method (GdViewer)
In This Topic
Returns the page height in PDF point units of the currently selected page in the displayed PDF document. If the document currently displayed in the GdViewer control is not the PDF file, the method will fail.
Syntax
'Declaration
 
Public Function PdfGetPageHeight() As Double
public double PdfGetPageHeight()
public function PdfGetPageHeight(): Double; 
public function PdfGetPageHeight() : double;
public: double PdfGetPageHeight(); 
public:
double PdfGetPageHeight(); 

Return Value

The page height in points. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only meaningful for PDF documents, otherwise it returns 0. It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

Just to inform you that 1 point = 1/72 inch. For example, to get the current page height in inches, use Height = PdfGetPageHeight() / 72, similarly to get the page height in centimeters, use Height = PdfGetPageHeight() / 72 * 2.54.

Example
How to retrieve the page height of the currently displayed page of the loaded PDF document.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim message As String = "The current file is: " + GdViewer1.GetLastPath()
    If GdViewer1.GetDocumentType() = DocumentType.DocumentTypePDF Then
        message += vbCrLf + "Number of pages: " + GdViewer1.PageCount.ToString() +
                   vbCrLf + "Page height: " + (GdViewer1.PdfGetPageHeight()) / 72 * 2.54 + " cm" +
                   vbCrLf + "Page width: " + (GdViewer1.PdfGetPageWidth()) / 72 * 2.54 + " cm"
    Else
        message += vbCrLf + "This file is not a PDF document, its format is: " + GdViewer1.GetDocumentType().ToString()
    End If
            
    MessageBox.Show(message, "GdViewer.PdfGetPageHeight")
Else
    MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PdfGetPageHeight")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string message = "The current file is: " + GdViewer1.GetLastPath();
    if (GdViewer1.GetDocumentType() == DocumentType.DocumentTypePDF)
    {
        message += "\nNumber of pages: " + GdViewer1.PageCount.ToString() +
                   "\nPage height: " + (GdViewer1.PdfGetPageHeight())/72*2.54 +
                   " cm\nPage width: " + (GdViewer1.PdfGetPageWidth())/72*2.54 + " cm";
    }
    else
    {
        message += "\nThis file is not a PDF document, its format is: " + GdViewer1.GetDocumentType().ToString();
    }
    MessageBox.Show(message, "GdViewer.PdfGetPageHeight");
}
else
    MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PdfGetPageHeight");
See Also