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
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.
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();
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