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.