Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
If fontEmbedded Then
Dim fontData As Byte() = Nothing
Dim fontFileData As String = fontName + "_fontData.dat"
status = gdpicturePDF.GetFontData(i, fontData)
If status = GdPictureStatus.OK Then
Dim oFileStream As System.IO.FileStream = Nothing
oFileStream = New System.IO.FileStream(fontFileData, System.IO.FileMode.Create)
oFileStream.Write(fontData, 0, fontData.Length)
oFileStream.Close()
output = output + "; Font data have been saved." + vbCrLf
Else
output = output + "; Font data have NOT been saved. Error (" + status.ToString() + ")" + vbCrLf
End If
End If
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: GetFontData")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontData")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetFontData")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
if (fontEmbedded)
{
byte[] fontData = null;
string fontFileData = fontName + "_fontData.dat";
status = gdpicturePDF.GetFontData(i, ref fontData);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = default(System.IO.FileStream);
oFileStream = new System.IO.FileStream(fontFileData, System.IO.FileMode.Create);
oFileStream.Write(fontData, 0, fontData.Length);
oFileStream.Close();
output = output + "; Font data have been saved.\n";
}
else
output = output + "; Font data have NOT been saved. Error (" + status.ToString() + ")\n";
}
}
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: GetFontData");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontData");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetFontData");
}
gdpicturePDF.Dispose();