Aspose.PDF.Generator Attachment link

Greetings,


I’ve been searching for a while on a way to attach files to my pdf, which I’ve managed, but I wanted to put an hyperlink for them in my table cell, which I did by doing the following code:

Dim attachment As New Generator.Attachment
attachment.AttachedFileType = "pdf"
attachment.AttachmentType = Generator.AttachmentType.File
attachment.AttachedStream = New System.IO.MemoryStream(myByteArrau)
attachment.AttachedFileName = myFileName
myCell.Paragraphs.Add(attachment)

It’s working fine, however, I was wondering if there was a way not to have the icon and put a normal blue hyperlink to them using the name of the file, instead of a very limited number of images provided by Aspose.Pdf. I know it’s possible for external files, external pdf or page references, but I’ve not seen anywhere about it being possible for an attachment.

Thank you and good day!
Nick

Hi Nick,


Thanks for contacting support.

We are working on generating the required code snippet and will get back to you soon.

Hi Nick,


Thanks for your patience.

You are using a legacy approach of PDF file creation. However we recommend using new Document Object Model of Aspose.Pdf namespace. This model offers the feature to create as well as manipulate existing PDF documents. It also supports the feature to Add Table in Existing PDF Document as well as it offers the feature to Create PDF Document Link in a PDF File. However as per my observations, when trying to add PDF file link in table cell, the link does not appear. For the sake of correction, I have logged this problem
as
PDFNEWNET-39521 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

[C#]

// Load source PDF document<o:p></o:p>

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();

doc.Pages.Add();

// Initializes a new instance of the Table

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

// Set the table border color as LightGray

table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));

// set the border for table cells

table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));

// create a loop to add 10 rows

for (int row_count = 1; row_count < 10; row_count++)

{

// add row to table

Aspose.Pdf.Row row = table.Rows.Add();

// add table cells

row.Cells.Add("Column (" + row_count + ", 1)");

row.Cells.Add("Column (" + row_count + ", 2)");

row.Cells.Add("Column 3");

LinkAnnotation link = new LinkAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(100, 100,150, 120));

link.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);

link.Action = new GoToRemoteAction("c:/pdftest/Input2.pdf", 1);

row.Cells[2].Paragraphs.Add(link);

}

// Add table object to first page of input document

doc.Pages[1].Paragraphs.Add(table);

// Save updated document containing table object

doc.Save(“c:/pdftest/document_with_table.pdf”);