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?
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.
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);
}
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)
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.