Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
'This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString()
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Status for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString()
MessageBox.Show(message, "Example: SetMeasurementUnit")
'You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
'This is the correct usage.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pLeft As Single = 0, pTop As Single = 0, pRight As Single = 0, pBottom As Single = 0
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, pLeft, pTop, pRight, pBottom)
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres." + vbCrLf + vbCrLf
End If
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pLeft As Single = 0, pTop As Single = 0, pRight As Single = 0, pBottom As Single = 0
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, pLeft, pTop, pRight, pBottom)
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") centimetres."
MessageBox.Show(message, "Example: SetMeasurementUnit")
End If
End If
Else
MessageBox.Show("This PDF has no pages.", "Example: SetMeasurementUnit")
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "Example: SetMeasurementUnit")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
//This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString();
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.GetStat();
message = message + "\nStatus for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString();
MessageBox.Show(message, "Example: SetMeasurementUnit");
//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";
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
//This is the correct usage.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float pLeft = 0, pTop = 0, pRight = 0, pBottom = 0;
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref pLeft, ref pTop, ref pRight, ref pBottom);
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres.\n\n";
}
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float pLeft = 0, pTop = 0, pRight = 0, pBottom = 0;
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref pLeft, ref pTop, ref pRight, ref pBottom);
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") centimetres.";
MessageBox.Show(message, "Example: SetMeasurementUnit");
}
}
}
else
{
MessageBox.Show("This PDF has no pages.", "Example: SetMeasurementUnit");
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "Example: SetMeasurementUnit");
}
gdpicturePDF.Dispose();