FileAttachmentAnnotation Pin is not displayed

Hello Aspose,

I’m using Apsose.PDF 24.4.0.0 as evaluation to migrate from Aspose.Pdf.Generator API.
I use this code to evaluate:

public static void Main()
{
string dataDir = “c:\temp\”;

        Document doc = new Document();
        Page page = doc.Pages.Add();
        var attachment = new FileAttachmentAnnotation(page,
                                                      new Rectangle(100, 100, 200, 200),
                                                      new FileSpecification("c:\\temp\\a.xml")
                                                      { MIMEType = "text/xml" })
                         {
                             Icon = FileIcon.Paperclip,
                             Color = Color.Red,
                         };
        page.Paragraphs.Add(attachment);
        dataDir += "FileAttachmentAnnotation.pdf";
        // Save the updated document
        doc.Save(dataDir);
    }

The file is contained in the generated PDF, but the paperclip is not visible if I view the PDF in Adobe Reader. Please see the attached screenshot.
If I view the same file in PDF XChange Editor the paperclip is displayed as expected.
Is there a workaround to display the clip in any viewer?
Or an alternative way to display a paperclip which launches a save dialog on an embeded file if clicked?

Regards
Gerd

2024-07-01 11_04_02-FileAttachmentAnnotation - PDF-XChange Editor.png (98.0 KB)
2024-07-01 10_59_34-Adobe.png (20.2 KB)
FileAttachmentAnnotation.pdf (6.1 MB)

@Gerd

Could you please try using the below code snippet and let us know if it resolves the issue:

Document doc = new Document();
var page = doc.Pages.Add();
//page.Paragraphs.Add(new TextFragment("File Attachment"));
//doc.ProcessParagraphs();
FileSpecification fs = new FileSpecification(dataDir + "input.pdf");
//doc.EmbeddedFiles.Add(fs);

//var absorber = new TextFragmentAbsorber();
//page.Accept(absorber);

//foreach (var fragment in absorber.TextFragments)
//{
    FileAttachmentAnnotation fileAttachment = new FileAttachmentAnnotation(page, new Rectangle(100, 100, 200, 200), fs);
    fileAttachment.Icon = FileIcon.Paperclip;
    // add FileAttachment Annotation to Annotations collection of first page
    //fileAttachment.Opacity = 0;
    fileAttachment.File.IncludeContents = false;
    page.Annotations.Add(fileAttachment);
//}
doc.Save(dataDir + "linktofile.pdf");

I will dig deeper whether the the icons will be displayed on the correct position on the correct page within my migration code. But the several PDF viewer are still displaying the paperclip differently.

Left is Adobe, right is PDF-XChange Editor in the attached screenshot.
2024-07-05 16_03_45-.png (140.5 KB)

BTW:
My original requirement is to display a button (=paperclip) close to a displayed thumpnail of an image attached in this document. The fuctionality was if the customer is clicking on the paperclip the ‘save file’ selection dialog is appearing when double clicking on the papaerclip.

@Gerd

Could you please create a sample PDF that you expect to produce using the API? We will try to create a code sample to achieve it and share with you.

This is eaxactly what I tried:
public static void Main()
{
string dataDir = “c:\temp\”;

        Document doc = new Document();
        Page page = doc.Pages.Add();

        // Any image
        var image = new Image();
        image.IsInNewPage = true;
        image.File = dataDir +"IMG_20240703_110914.jpg";
        page.Paragraphs.Add(image);
        page.Paragraphs.Add(image);
        page.Paragraphs.Add(image);

        // Table for attachment
        var table = new Table()
                    {
                        Broken = TableBroken.None,
                        IsBroken = false,
                        RepeatingColumnsCount = 0,
                        RepeatingRowsCount = 0,
                        ColumnWidths = "10% 90%",
                        IsInNewPage = true
                    };

        // Any file to attach
        var fs = new FileSpecification(dataDir + "a.xml");
        var attachment = new FileAttachmentAnnotation(page,
                                                      new Rectangle(0, 36, 0, 36),
                                                      fs)
                         {
                             Icon = FileIcon.Paperclip,
                             Color = Color.Red,
                             
                         };
        attachment.File.IncludeContents = false;

        var row = new Row();

        // left cell with paperclip to enable a file download if double clicked
        var c1 = new Cell();
        c1.Paragraphs.Add(attachment);
        
        // right cell with thumbnail
        var c2 = new Cell();
        c2.Paragraphs.Add(image);

        row.Cells.Add(c1);
        row.Cells.Add(c2);
        table.Rows.Add(row);
        page.Paragraphs.Add(table);

        //page.Annotations.Add(attachment);
        //page.Paragraphs.Add(attachment);
        dataDir += "FileAttachmentAnnotation.pdf";
        // Save the updated document
        doc.Save(dataDir);

    }

FileAttachmentAnnotation.7z (7.1 MB)

PDF-XChange Viewer perfectly shows what I expect.
PDF-XChange.png (271.4 KB)
Adobe does not show the paperclip, but the attachment exists.
Adobe Acrobat Pro (64-bit).jpg (148.5 KB)

My goal is to have an icon close to the thumbnail (like the paperclip) the user clicks on and the file save dialog appears after a (security warning).

@Gerd

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-57611

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.