Reference Guide
GdPicture14 Namespace / GdPicturePDF Class / GetMeasurementUnit Method
Example





In This Topic
    GetMeasurementUnit Method (GdPicturePDF)
    In This Topic
    Returns the currently used measurement units defined in the loaded PDF document. Please note that you need to create or load the PDF document properly to get the valid value, otherwise the value is undefined.
    Syntax
    'Declaration
     
    
    Public Function GetMeasurementUnit() As PdfMeasurementUnit
    public PdfMeasurementUnit GetMeasurementUnit()
    public function GetMeasurementUnit(): PdfMeasurementUnit; 
    public function GetMeasurementUnit() : PdfMeasurementUnit;
    public: PdfMeasurementUnit GetMeasurementUnit(); 
    public:
    PdfMeasurementUnit GetMeasurementUnit(); 

    Return Value

    A member of the PdfMeasurementUnit enumeration. The default value is PdfMeasurementUnit.PdfMeasurementUnitPoint.

    The GetStat method can be subsequently used to determine if this method has been successful.

    Remarks
    It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

    All locations and sizes in PDF document are stored in a logical value called a PDF point. 1 point is equivalent to 1/72 of an inch.

    The standard PDF measurement units are: point, milimeter, centimeter, inch. The default PDF measurement units are points.

    Example
    How to find out the currently set measurement units.
    Dim oGdPicturePDF As New GdPicturePDF()
    Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
                
    'The values obtained here are undefined.
    Dim origin As PdfOrigin = oGdPicturePDF.GetOrigin()
    Dim status As GdPictureStatus = oGdPicturePDF.GetStat()
    message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString()
    Dim units As PdfMeasurementUnit = oGdPicturePDF.GetMeasurementUnit()
    status = oGdPicturePDF.GetStat()
    message = message + vbCrLf + "Units: " + units.ToString() + "    status: " + status.ToString()
    MessageBox.Show(message, "Example: GetMeasurementUnit")
                
    'You need to load the file here.
    status = oGdPicturePDF.LoadFromFile("testPDF.pdf", False) ' you need to load the file here
    If status = GdPictureStatus.OK Then
        message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
        'The values obtained here are correctly defined.
        origin = oGdPicturePDF.GetOrigin()
        status = oGdPicturePDF.GetStat()
        message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString()
        units = oGdPicturePDF.GetMeasurementUnit()
        status = oGdPicturePDF.GetStat()
        message = message + vbCrLf + "Units: " + units.ToString() + "    status: " + status.ToString()
        MessageBox.Show(message, "Example: GetMeasurementUnit")
    Else
        MessageBox.Show("The file can't be loaded.", "Example: GetMeasurementUnit")
    End If
                
    oGdPicturePDF.Dispose()
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    string message = "NO document IS loaded.\n\n";
                
    //The values obtained here are undefined.
    PdfOrigin origin = oGdPicturePDF.GetOrigin();
    GdPictureStatus status = oGdPicturePDF.GetStat();
    message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString();
    PdfMeasurementUnit units = oGdPicturePDF.GetMeasurementUnit();
    status = oGdPicturePDF.GetStat();
    message = message + "\nUnits: " + units.ToString() + "    status: " + status.ToString();
    MessageBox.Show(message, "Example: GetMeasurementUnit");
                
    //You need to load the file here.
    status = oGdPicturePDF.LoadFromFile("test.pdf", false);
    if (status == GdPictureStatus.OK)
    {
        message = "Your pdf document IS loaded.\n\n";
        //The values obtained here are correctly defined.
        origin = oGdPicturePDF.GetOrigin();
        status = oGdPicturePDF.GetStat();
        message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString();
        units = oGdPicturePDF.GetMeasurementUnit();
        status = oGdPicturePDF.GetStat();
        message = message + "\nUnits: " + units.ToString() + "    status: " + status.ToString();
        MessageBox.Show(message, "Example: GetMeasurementUnit");
    }
    else
    {
        MessageBox.Show("The file can't be loaded.", "Example: GetMeasurementUnit");
    }
                
    oGdPicturePDF.Dispose();
    See Also