I recently faced this problem myself where I wanted to show search results which will search for words inside document attachments. The idea was to show these attachments as links in the search results. I wrote this small method that can be put inside a transformation and method can be called by sending two parameters.
public void Transformation(int documentID, string NodeAliasPath)
string htmlCode = null;
// enter your attachment guid. You can find this value in the page type field.
var fieldGUID = "";
// get attachments for given document and field
var attachmentsOfField = CMS.DocumentEngine.AttachmentInfoProvider.GetAttachments().WhereEquals("AttachmentGroupGUID", fieldGUID).And().WhereEquals("AttachmentDocumentID", documentID);
foreach (var attachment in attachmentsOfField)
// get url of attachment
string attachmentUrl = CMS.Helpers.URLHelper.GetAbsoluteUrl(CMS.DocumentEngine.AttachmentURLProvider.GetAttachmentUrl(attachment.AttachmentGUID, NodeAliasPath));
// append html code with the url
htmlCode += "<a href=\"" + attachmentUrl + "\">" + attachment.AttachmentName + "</a><br>";