使用 C# API 進行文件註釋

使用 Aspose.Total for .NET 對 Microsoft Word、Excel 電子表格、PowerPoint 簡報和 PDF 文件進行註解。

 

文件註解是指向文件新增元資料、註解或其他類型的資訊以提供附加上下文或突出顯示文件中的特定元素的過程。 註釋可以包括文字註釋、突出顯示、形狀、註釋和其他類型的標記,幫助使用者理解文件內容或與文件內容互動。 文件註釋通常用於法律、醫療保健、教育和商業等各個行業,用於文件審查、協作和分析等任務。

透過基於 .NET 的應用程式管理文件註解利用 .NET 框架與 Microsoft 技術的集成,提供與 Microsoft Office、SharePoint 和 Azure 的無縫相容性。該框架豐富的庫支援、強大的類型和語言功能,以及其安全性和效能優化,使其成為建立處理和操作帶有註釋文件的應用程式的首選。

註解 Microsoft Word 文件

使用 Aspose.Total 對 Microsoft Word 文件進行註解具有一系列優勢,可滿足開發人員和企業的不同需求。 首先,Aspose.Total的跨平台相容性確保開發人員可以將文件註釋功能無縫整合到跨Windows、Linux和macOS環境的應用程式中。 Aspose.Words 是 Aspose.Total 的關鍵元件,提供了多種註釋類型,包括文字、區域和點註釋,為開發人員提供了解決特定用例的靈活性。

另一個顯著優勢在於 Aspose.Total 函式庫的高效能。 這些庫經過最佳化,可以有效地處理帶有註釋的大型 Word 文檔,滿足需要即時註釋或處理大量文檔集的應用程式的需求。 Aspose.Words 提供的豐富的格式和樣式選項使開發人員能夠自訂註釋的視覺效果,從而增強註釋文件的清晰度和呈現方式。

C# 程式碼 - 提取所有註釋

Document docx = new Document("input.docx");
ArrayList collectedComments = new ArrayList();
NodeCollection comments = docx.GetChildNodes(NodeType.Comment, true);
foreach (Comment comment in comments){
collectedComments.Add(comment.Author + " " + comment.DateTime + " " + comment.ToString(SaveFormat.Text));
//print
}

C# 程式碼 - 刪除特定作者的評論

Document docx = new Document("input.docx");
NodeCollection comments = docx.GetChildNodes(NodeType.Comment, true);
for (int i = comments.Count - 1; i >= 0; i--){
Comment comment = (Comment)comments[i];
if (comment.Author == authorName)
comment.Remove();
}

註釋 Powerpoint PPT PPTX 簡報

要使用 Aspose.Total for .NET 註釋 PowerPoint 簡報,您將主要利用 Aspose.Slides for .NET 庫。 該庫提供了用於處理 Microsoft PowerPoint 文件的全面功能,包括新增註釋的功能。 以下 C# 程式碼片段示範如何使用 Aspose.Slides for .NET 對 PowerPoint 簡報進行註解:

C# 程式碼 - 在 Powerpoint 簡報中新增註釋

C# 程式碼 - 從 Powerpoint 簡報中刪除評論作者

C# 應用程式中的 PDF 註釋

使用 Aspose.Total 註釋 PDF 文件為希望增強 PDF 操作能力的開發人員和企業提供了全面的解決方案。 Aspose.PDF 是 Aspose.Total 的關鍵元件,提供強大的 API,使開發人員能夠將註解功能無縫整合到他們的應用程式中。 憑藉跨平台相容性,Aspose.Total 確保開發人員可以跨不同作業系統(包括 Windows、Linux 和 macOS)部署 PDF 文件註解功能。

Aspose.PDF 支援各種註釋,這種靈活性允許開發人員為其特定用例選擇最合適的註釋類型。

C# 程式碼 - 在 PDF 檔案中新增註釋

Document pdfDocument = new Document();
Page targetPage = pdfDocument.Pages.Add();
targetPage.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Here are the sample contents of the PDF"));
TextAnnotation annotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(220, 420, 420, 620)){
Title = "Title of the annotation",
Subject = "Subject of the annotation",
State = AnnotationState.Accepted,
Contents = "Contents of the annotation",
Open = true,
Icon = TextIcon.Key
};
Border border = new Border(annotation) {
Width = 6,
Dash = new Dash(1, 1)
};
annotation.Border = border;
pdfDocument.Pages[1].Annotations.Add(annotation);
pdfDocument.Save("AnnotatedPdf.pdf");