Dim caption As String = "Example: AddTrueTypeFont"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim fontResNameBold As String = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", True, False, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim fontResNameBoldItalic As String = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", True, True, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResNameBold, 10, 50, "Here is some bold text") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResNameBoldItalic, 10, 100, "Here is some bold italic text") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFont.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully. Both fonts have been added to the newly created document.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddTrueTypeFont() method for bold italic font has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
Else
MessageBox.Show("The AddTrueTypeFont() method for bold font has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFont";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
string fontResNameBold = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", true, false, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string fontResNameBoldItalic = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", true, true, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResNameBold, 10, 50, "Here is some bold text") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResNameBoldItalic, 10, 100, "Here is some bold italic text") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFont.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully. Both fonts have been added to the newly created document.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddTrueTypeFont() method for bold italic font has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
else
{
MessageBox.Show("The AddTrueTypeFont() method for bold font has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();