I noticed an issue when changing color of text within link rectangle using AsposePDF v18.10.0.0
Please see attached “input.pdf” and “output.pdf”.
input.pdf : Before changing color of text within link rectangle
output.pdf: After changing color of text using AsposePDF.net v18.10.0.0
Description: When we compare output.pdf file, after the word “from” having more space and word
“minutes” is overlapped(Gibberished)
I used following code to change color of a text using Aspose.PDF v18.10.0.0
//***Code Start
private void btnChangeColor_Click(object sender, EventArgs e)
{
try
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.Embedded = true;
license.SetLicense(“`Aspose`.Pdf.lic”);
Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(@"D:\test\inputput.pdf);
Aspose.Pdf.Page page = pdf.Pages[1];
Aspose.Pdf.Rectangle AnnotRect = new Aspose.Pdf.Rectangle(80, 540, 270, 560);
LinkAnnotation link = new LinkAnnotation(page, AnnotRect);
XYZExplicitDestination mag = new XYZExplicitDestination(page, 0, page.MediaBox.Height, 0);
link.Action = new GoToAction(mag);
System.Drawing.Color color2 = System.Drawing.ColorTranslator.FromHtml("#008000");
link.Color = Aspose.Pdf.Color.FromRgb(color2);
Border border = new Border(link);
border.Style = Aspose.Pdf.Annotations.BorderStyle.Solid;
link.Border = border;
page.Annotations.Add(link);
foreach (Annotation annotation in page.Annotations)
{
if (annotation is LinkAnnotation)
{
Aspose.Pdf.Rectangle rect = annotation.Rect;
TextFragmentAbsorber absorber = new TextFragmentAbsorber();
absorber.TextSearchOptions.Rectangle = rect;
page.Accept(absorber);
foreach (TextFragment textFragment in absorber.TextFragments)
{
System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("#FF0000");
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(color);
}
}
}
pdf.Save(@"D:\test\output.pdf");
MessageBox.Show("The PDF File is saved at the location of @"D:\test\output.pdf");
}
catch (Exception ex)
{
MessageBox.Show("Some Error Encountered" + ex.toString());
}
}
//***Code End
input.pdf (34.9 KB)
output.pdf (61.2 KB)
Can you please look into this issue and Let me know is there issue in Aspose.PDF or Am I doing something incorrect here?
Please let me know if you need any more information on this.