We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Hyperlink color not set in pdf


I am trying to set hyperlink color to existing pdf file using below code, after below code execution hyperlink work ok but color of text on which i set the hyper link was not change to blue.

Document doc = new Document(“filename”);

float shapeX = (shapes[i].x * 72 / 150) / (float)Convert.ToDouble(shapes[i].ratio);
float shapeY = (shapes[i].y * 72 / 150) / (float)Convert.ToDouble(shapes[i].ratio);
float shapeW = (shapes[i].w * 72 / 150) / (float)Convert.ToDouble(shapes[i].ratio);
float shapeH = (shapes[i].h * 72 / 150) / (float)Convert.ToDouble(shapes[i].ratio);

double yaxis = (float)(doc.Pages[shapes[i].p].Rect.URY - (shapeH + shapeY));

Page page = doc.Pages[shapes[i].p];
// Create Link annotation object

LinkAnnotation link = new LinkAnnotation(page, new Aspose.Pdf.Rectangle(shapeX, yaxis, shapeW + shapeX, yaxis + shapeH));
// Create border object for LinkAnnotation
Border border = new Border(link);
// Set the border width value as 0
border.Width = 0;
// Set the border for LinkAnnotation
link.Border = border;
link.Color = Aspose.Pdf.Color.Blue;
link.Action = new GoToURIAction(url);

Please let me know is there anything missing?

Hi Viral,

Thanks for your inquiry. Please check following documentation link for setting Hyperlink color. You can use same rectangle values for text. However, if you face any issue then please share your PDF document along with rectangle values, so we will guide you accordingly.

Best Regards,

This formula work if the document rotation None. But if the document rotation is on90, on180 and on270 its not work.
Is there any correct formula to calculate correct position?


We have responded to your similar query in this thread and your response is awaited there.