Dim caption As String = "Example: GetTextWidth"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetTextWidth(fontName, 20, "I love GdPicture.NET")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of your text ""I love GdPicture.NET"" using the Times-Roman font with the size 20 is " + width.ToString() + " centimeters.", caption)
Else
MessageBox.Show("The GetTextWidth() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Units can't be set correctly.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetTextWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetTextWidth(fontName, 20, "I love GdPicture.NET");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of your text \"I love GdPicture.NET\" using the Times-Roman font with the size 20 is " + width.ToString() + " centimeters.", caption);
else
MessageBox.Show("The GetTextWidth() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("Units can't be set correctly.", caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();