Dim caption As String = "Example: AddLinkToPageAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
gdpicturePDF.SelectPage(1)
Dim textSize As Single = 20
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 140, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim textW As Single = gdpicturePDF.GetTextWidth(fontResName, textSize, "Goto Page 2")
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim textH As Single = gdpicturePDF.GetTextHeight(fontResName, textSize, False)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
If (status1 = GdPictureStatus.OK) AndAlso (status2 = GdPictureStatus.OK) Then
If gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 2") = GdPictureStatus.OK Then
'The currently selected page is 1.
Dim annotID As Integer = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 2, 0, 0, True, 0, 0, 255)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Please always select the required page before adding an annotation.
If (gdpicturePDF.SelectPage(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 140, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 1") = GdPictureStatus.OK) Then
'The currently selected page is 2.
annotID = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 1, 0, 0, True, 0, 0, 255)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("linkpageannot.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file has NOT been saved. Status: " + gdpicturePDF.GetStat(), caption)
End If
Else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption)
End If
Else
MessageBox.Show("Adding font and its properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkToPageAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
gdpicturePDF.SelectPage(1);
float textSize = 20;
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 140, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
float textW = gdpicturePDF.GetTextWidth(fontResName, textSize, "Goto Page 2");
GdPictureStatus status1 = gdpicturePDF.GetStat();
float textH = gdpicturePDF.GetTextHeight(fontResName, textSize, false);
GdPictureStatus status2 = gdpicturePDF.GetStat();
if ((status1 == GdPictureStatus.OK) && (status2 == GdPictureStatus.OK))
{
if (gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 2") == GdPictureStatus.OK)
{
//The currently selected page is 1.
int annotID = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 2, 0, 0, true, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Please always select the required page before adding an annotation.
if ((gdpicturePDF.SelectPage(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 140, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 1") == GdPictureStatus.OK))
{
//The currently selected page is 2.
annotID = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 1, 0, 0, true, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("linkpageannot.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file has NOT been saved. Status: " + gdpicturePDF.GetStat(), caption);
}
else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption);
}
else
MessageBox.Show("Adding font and its properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();