GdPicture.NET.14
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 gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
            
'The values obtained here are undefined.
Dim origin As PdfOrigin = gdpicturePDF.GetOrigin()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString()
Dim units As PdfMeasurementUnit = gdpicturePDF.GetMeasurementUnit()
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Units: " + units.ToString() + "    status: " + status.ToString()
MessageBox.Show(message, "Example: GetMeasurementUnit")
            
'You need to load the file here.
status = gdpicturePDF.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 = gdpicturePDF.GetOrigin()
    status = gdpicturePDF.GetStat()
    message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString()
    units = gdpicturePDF.GetMeasurementUnit()
    status = gdpicturePDF.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
            
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
            
//The values obtained here are undefined.
PdfOrigin origin = gdpicturePDF.GetOrigin();
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString();
PdfMeasurementUnit units = gdpicturePDF.GetMeasurementUnit();
status = gdpicturePDF.GetStat();
message = message + "\nUnits: " + units.ToString() + "    status: " + status.ToString();
MessageBox.Show(message, "Example: GetMeasurementUnit");
            
//You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    message = "Your pdf document IS loaded.\n\n";
    //The values obtained here are correctly defined.
    origin = gdpicturePDF.GetOrigin();
    status = gdpicturePDF.GetStat();
    message = message + "Origin: " + origin.ToString() + "    status: " + status.ToString();
    units = gdpicturePDF.GetMeasurementUnit();
    status = gdpicturePDF.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");
}
            
gdpicturePDF.Dispose();
See Also