Dim caption As String = "Example: AddLinkAnnotation"
Dim gdpicturePDF As New GdPicturePDF()
Dim failure As Boolean = True
Dim textSize As Single = 12, textWidth As Single = 0, textHeight As Single = 0
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf2.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf1.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat().ToString(), caption)
Else
failure = True
status = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf1.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf2.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat(), caption)
Else
MessageBox.Show("The example HAS been successfully followed." + vbCrLf + "Both newly created PDF documents are linked together.", caption)
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
bool failure = true;
float textSize = 12, textWidth = 0, textHeight = 0;
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf2.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf1.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat().ToString(), caption);
else
{
failure = true;
status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf1.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf2.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat(), caption);
else
MessageBox.Show("The example HAS been successfully followed.\nBoth newly created PDF documents are linked together.", caption);
}
gdpicturePDF.Dispose();