Hi Aspose Team,
We are trying to create a link annotation with page break (like few text in first page and few text in second page) using below code. but we are failed to create link annotation in 2 different page same time. Refer the attached PDF file & image file.
Please help to create link annotation with page break.
NOTE: its very high priority. Please help me ASAP
TextFragmentCollection textFragmentCollection;
Document doc = new Document(pdf);
TextFragmentAbsorber textFragmentAbsorber;
textFragmentAbsorber = new TextFragmentAbsorber(kv.Key, new TextSearchOptions(true));
doc.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments
textFragmentCollection = textFragmentAbsorber.TextFragments;
if (textFragmentCollection.Count > 0)
{
foreach (TextFragment textFragment in textFragmentCollection)
{
// Use the text segments when the text fragment has a newline char.
if (textFragment.Text.Contains(Environment.NewLine))
{
foreach (TextSegment s in textFragment.Segments)
{
// Create the annotation for each segment.
s.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
LinkAnnotation link = new LinkAnnotation(textFragment.Page, s.Rectangle);
Aspose.Pdf.Point start = new Aspose.Pdf.Point(s.Rectangle.LLX, s.Rectangle.LLY);
Aspose.Pdf.Point end = new Aspose.Pdf.Point(s.Rectangle.LLX + s.Rectangle.Width, s.Rectangle.LLY);
LineAnnotation line = new LineAnnotation(textFragment.Page, s.Rectangle, start, end);
line.Color = Aspose.Pdf.Color.Blue;
line.Border = new Border(link) { Width = 1 };
link.Border = new Border(link) { Width = 0 };
s.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
link.Action = new GoToURIAction(kv.Value);
textFragment.Page.Annotations.Add(link);
textFragment.Page.Annotations.Add(line);
}
}
}
}
Regards,
Ganesan. BHi Aspose Team,
We are trying to create a link annotation with page break (like few text in first page and few text in second page) using below code. but we are failed to create link annotation in 2 different page same time. Refer the attached PDF file & image file.
TextFragmentCollection textFragmentCollection;
Document doc = new Document(pdf);
TextFragmentAbsorber textFragmentAbsorber;
textFragmentAbsorber = new TextFragmentAbsorber(kv.Key, new TextSearchOptions(true));
doc.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments
textFragmentCollection = textFragmentAbsorber.TextFragments;
if (textFragmentCollection.Count > 0)
{
foreach (TextFragment textFragment in textFragmentCollection)
{
// Use the text segments when the text fragment has a newline char.
if (textFragment.Text.Contains(Environment.NewLine))
{
foreach (TextSegment s in textFragment.Segments)
{
// Create the annotation for each segment.
s.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
LinkAnnotation link = new LinkAnnotation(textFragment.Page, s.Rectangle);
Aspose.Pdf.Point start = new Aspose.Pdf.Point(s.Rectangle.LLX, s.Rectangle.LLY);
Aspose.Pdf.Point end = new Aspose.Pdf.Point(s.Rectangle.LLX + s.Rectangle.Width, s.Rectangle.LLY);
LineAnnotation line = new LineAnnotation(textFragment.Page, s.Rectangle, start, end);
line.Color = Aspose.Pdf.Color.Blue;
line.Border = new Border(link) { Width = 1 };
link.Border = new Border(link) { Width = 0 };
s.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
link.Action = new GoToURIAction(kv.Value);
textFragment.Page.Annotations.Add(link);
textFragment.Page.Annotations.Add(line);
}
}
}
}
Regards,
Ganesan. B