Dim caption As String = "Example: SetBookmarkAction"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
Else
Dim rootBookmark As Integer = gdpicturePDF.NewBookmark(0, "Pages Navigation")
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NewBookmark() method (root bookmark) has failed with the status: " + status.ToString(), caption)
Else
Dim failure As Boolean = True
Dim i As Integer = 0
Do
i += 1
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim bookMarkID As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString())
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) <> GdPictureStatus.OK)
End If
End If
End If
If failure Then
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Loop While Not failure AndAlso i < 10
If Not failure AndAlso (gdpicturePDF.SaveToFile("bookmarks_Actions.pdf") = GdPictureStatus.OK) Then
MessageBox.Show("The new file has been saved successfully.", caption)
Else
MessageBox.Show("The new file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The new file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkAction";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
else
{
int rootBookmark = gdpicturePDF.NewBookmark(0, "Pages Navigation");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The NewBookmark() method (root bookmark) has failed with the status: " + status.ToString(), caption);
else
{
bool failure = true;
int i = 0;
do
{
i++;
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int bookMarkID = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString());
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) != GdPictureStatus.OK);
}
}
}
if (failure)
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption);
} while (!failure && i < 10);
if (!failure && (gdpicturePDF.SaveToFile("bookmarks_Actions.pdf") == GdPictureStatus.OK))
MessageBox.Show("The new file has been saved successfully.", caption);
else
MessageBox.Show("The new file can't be saved.", caption);
}
}
}
else
{
MessageBox.Show("The new file can't be created.", caption);
}
gdpicturePDF.Dispose();