PDF에서 첨부파일 제거

Contents
[ ]

Aspose.PDF는 PDF 파일에서 첨부파일을 제거할 수 있습니다. PDF 문서의 첨부파일은 Document 객체의 EmbeddedFiles 컬렉션에 저장됩니다.

다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.

PDF 파일과 관련된 모든 첨부파일을 삭제하려면:

  1. EmbeddedFiles 컬렉션의 Delete 메서드를 호출합니다.
  2. Document 객체의 Save 메서드를 사용하여 업데이트된 파일을 저장합니다.

다음 코드 스니펫은 PDF 문서에서 첨부파일을 제거하는 방법을 보여줍니다.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeleteAllAttachments()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Attachments();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "DeleteAllAttachments.pdf"))
    {
        // Delete all attachments
        document.EmbeddedFiles.Delete();

        // Save PDF document
        document.Save(dataDir + "DeleteAllAttachments_out.pdf");
    }
}