使用 C++ API 進行文件註釋

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

 

文件註釋是指向文件添加元資料、註釋、突出顯示或其他標記以增強其可讀性、組織性和協作性的過程。 此程序可套用於各種類型的文檔,包括 Microsoft Word、Excel、PowerPoint 和 PDF 文件。註釋有多種用途,例如提供附加上下文、澄清資訊、突出顯示重點或促進多個使用者之間的協作。

開發用於註解 Microsoft Office 文件和 PDF 文件的 C++ 應用程式有幾個優點。 C++ 是一種高效能語言,以其效率和速度而聞名,使其適合快速處理大型且複雜的文件。 此外,Aspose.Total 等 C++ 程式庫以及與 DOCX、XLSX、PPTX 和 PDF 等文件格式互動的框架,使開發人員能夠無縫實現註解功能。 此外,透過以 C++ 開發獨立應用程序,使用者可以離線註釋文檔,而無需依賴網路連線或第三方服務,確保資料隱私和安全。

註解 Microsoft Word DOC DOCX 文檔

在 Microsoft Word 中,註釋允許使用者新增註釋、追蹤變更、插入腳註或突出顯示文字以在文件中提供回饋、建議或其他資訊。 這在多個作者或審閱者同時處理同一文件的協作環境中特別有用。

C++ 程式碼 - 在 Word 文件中加入註釋

System::String outputDataDir = GetOutputDataDir_WorkingWithComments();
System::SharedPtr<Document> doc = System::MakeObject<Document>();
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc);
builder->Write(u"Some text is added.");
System::SharedPtr<Comment> comment = System::MakeObject<Comment>(doc, u"Author Name", u"AN", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild(comment);
comment->get_Paragraphs()->Add(System::MakeObject<Paragraph>(doc));
comment->get_FirstParagraph()->get_Runs()->Add(System::MakeObject<Run>(doc, u"Comment text."));
System::String outputPath = outputDataDir + u"AddComments.doc";
doc->Save(outputPath);

為 Powerpoint 簡報新增註釋

在 Microsoft PowerPoint 中,註釋允許簡報者將演講者備註、評論或註釋直接新增到投影片上,以在簡報期間提供附加上下文、提醒或解釋。 這增強了演示的交付並確保觀眾收到全面的訊息。

若要使用 Aspose.Total for C++ 註解 PowerPoint 簡報,您將主要利用 Aspose.Slides for C++ 函式庫。 該庫提供了用於處理 Microsoft PowerPoint 文件的全面功能,包括新增註釋的功能。

C++ 程式碼 - 刪除 Powerpoint 簡報中的註釋

using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System::Drawing;
auto presentation = System::MakeObject<Presentation>(u"example.ppt");
for (auto author : presentation->get_CommentAuthors()){
author->get_Comments()->Clear();
}
presentation->get_CommentAuthors()->Clear();
presentation->Save(u"example_out.pptx", SaveFormat::Pptx);

C++ 應用程式中的 PDF 註釋

PDF 文件還受益於註釋功能,允許使用者添加註釋、突出顯示、圖章或繪圖來註釋文字、圖像或圖表。 這在審查和協作文件、填寫表格或添加簽名以驗證文件時特別有用。

Aspose.PDF 是 Aspose.Total 的關鍵元件,提供強大的 API,使開發人員能夠將註解功能無縫整合到他們的應用程式中。 Aspose.Total 確保開發人員可以在 C++ 應用程式中部署 PDF 文件註解功能。

C++ 程式碼 - 刪除 PDF 檔案中的文字註釋

String _dataDir("C:\\Samples\\");
auto document = MakeObject<Document>(_dataDir + u"sample_textannot.pdf");
auto page = document->get_Pages()->idx_get(1);
auto annotationSelector = MakeObject<Aspose::Pdf::Annotations::AnnotationSelector>(
MakeObject<Aspose::Pdf::Annotations::LineAnnotation>(page, Rectangle::get_Trivial(), Point::get_Trivial(), Point::get_Trivial()));
page->Accept(annotationSelector);
auto textAnnotations = annotationSelector->get_Selected();
for (auto fa : textAnnotations) {
page->get_Annotations()->Delete(fa);
}
document->Save(_dataDir + u"sample_textannot_del.pdf");