Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
添付ファイルにはさまざまな情報を含めることができ、さまざまなファイルタイプが使用できます。この記事では、PDFファイルに添付ファイルを追加する方法について説明します。
次のコードスニペットは、Aspose.Drawingライブラリでも機能します。
EmbeddedFilesコレクションには、PDFファイル内のすべての添付ファイルが含まれています。次のコードスニペットは、PDFドキュメントに添付ファイルを追加する方法を示しています。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddEmbeddedFile()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Attachments();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "AddAttachment.pdf"))
{
// Setup new file to be added as attachment
Aspose.Pdf.FileSpecification fileSpecification = new Aspose.Pdf.FileSpecification(dataDir + "test.txt", "Sample text file");
// Add attachment to document's attachment collection
document.EmbeddedFiles.Add(fileSpecification);
// Save PDF document
document.Save(dataDir + "AddAnnotations_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.