Adding a text label next to attachment in PDF?

Hi,

I want to create a PDF document with attached documents.
That works great, I get a nice icon in my PDF document.

Now I want to add a name to that attachement, next to that icon.
E.g. when I add a word file with a customer review in the PDF document I want to have the icon and right next to it “customer review”.

I’ve searched the documentation for this, but all I could find was the possibility to add notes to the attachment icon. This is not what I’m looking for since I need to move over the icon with my cursor to view the note. I want to have it visible at all times.

A screenshot of what I have now in the generated PDF document:
http://i29.tinypic.com/bhcwn.jpg

An edited screenhot of what I’m looking for to accomplish in the generated PDF document:
http://i26.tinypic.com/20zd8w7.jpg

Is it possible to generate the PDF document this way ?

To add the attachment I’m using this code:

//Instantiate attachment instance by calling its empty constructor
Attachment fileAttachment = new Attachment();

//Add attachment in the paragraphs collection of the section
sec1.Paragraphs.Add(fileAttachment);

//Set attachment type to File using AttachmentType enumeration
fileAttachment.AttachmentType = AttachmentType.File;

//Set the path of the attachment file
fileAttachment.AttachedFileName = "C:/ps4BA15.doc";
fileAttachment.NoteContent = "customer review";

//Set the type of the file to be attached
fileAttachment.AttachedFileType = "doc";

Thanks in advance!
Kurt

Hello Kurt,

Thanks for considering Aspose.

Aspose.Pdf has a great feature named Floating Box, its a sub-class of Paragraph and it can contain one or more paragraphs and the best part is you can place it any where in the document. Using this feature you can display the name of Attachments next to an icon. Please try the following code snippet and in case of any concerned issue, please feel free to share.

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.Sections.Add();

Attachment fileAttachment = new Attachment();
sec1.Paragraphs.Add(fileAttachment);
fileAttachment.AttachmentType = AttachmentType.File;
fileAttachment.AttachedFileName = @"C:/pdftest/Document.pdf";
fileAttachment.AttachedFileType = "pdf";
fileAttachment.FileIconType = FileIconType.PaperClip;

FloatingBox box1 = new FloatingBox(108,80);
sec1.Paragraphs.Add(box1);
box1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Margin;
box1.Left = 20;
box1.BoxVerticalPositioning = BoxVerticalPositioningType.Page;
box1.Top = 70;
int Slash = fileAttachment.AttachedFileName.IndexOf('/',3);
int Dot = fileAttachment.AttachedFileName.IndexOf('.', Slash);
box1.Paragraphs.Add(new Text("" + fileAttachment.AttachedFileName.Substring(Slash+1,Dot-(Slash+1))));

pdf1.Save("C:\\pdftest\\attachment_test.pdf");

For more information on floating box kindly visit Let's start with Hello.

That approach works great, thanks!