function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chikkuchikku 

How to add hyper link in pdf attachment in vf page

My requirement is I need to add the hyperlink in the pdf attachment in an email.
when they click the links in the email, there should navigate to the current record id. (For example, if I click that link in the email which  I received then that should navigate to contact record page with respective contact id)

It possible guys?
 
Best Answer chosen by chikku
ShivankurShivankur (Salesforce Developers) 
Hi Chikku,

Thanks for adding more clarity to the question.

If you are implementing a Visualforce Email Template then you have default tool available to add links to your template:
Add email link to custom or letterhead HTML templates (https://help.salesforce.com/articleView?id=000325946&type=1&mode=1)

If you are looking to implement via Apex then can use below line in Email body while sending email:
URL.getSalesforceBaseUrl().toExternalForm() + '/' + contact.Id
You can replace the contact.Id with the object record id which you want.

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.

All Answers

ShivankurShivankur (Salesforce Developers) 
Hi Chikku,

You can use apex:outputLink in your visualforce page to provide users a link inside the PDF generated.

For navigation across the Salesforce data as to access the contact record, the user should be logged on from the same machine so the navigation would work for them, if the user is not logged in and clicks the link in the PDF, they will be redirected to login page.

Reference for Usage of apex:outputLink :
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputLink.htm

Also, refer this guide for more use case scenarios/examples on the same:
https://www.developerforce.com/guides/Visualforce_in_Practice.pdf

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.
Mark JenniferMark Jennifer
To target an HTML link to a specific page in a PDF file, add #page=[page number] to the end of the link's URL. I also add some Hyperlinks in my commercial (https://www.ideasanimation.net/commercials/) data pdf file. I also don't know how to add hypelink in pdf attachment. Then I see this guide.

Also, refer this guide for more use case scenarios/examples on the same:
https://www.developerforce.com/guides/Visualforce_in_Practice.pdf

This Guide give the answers of your all Questions related to pdf attachements. 
chikkuchikku
Hi Shivankur,
I need to show the link in email, not in pdf . if I click that link it should generate to that record page with a current record of the object(contact)
 
ShivankurShivankur (Salesforce Developers) 
Hi Chikku,

Thanks for adding more clarity to the question.

If you are implementing a Visualforce Email Template then you have default tool available to add links to your template:
Add email link to custom or letterhead HTML templates (https://help.salesforce.com/articleView?id=000325946&type=1&mode=1)

If you are looking to implement via Apex then can use below line in Email body while sending email:
URL.getSalesforceBaseUrl().toExternalForm() + '/' + contact.Id
You can replace the contact.Id with the object record id which you want.

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.
This was selected as the best answer