從 Java 註釋 VSD


下載免費試用版

關於 Java API 的 GroupDocs.Annotation

GroupDocs.Annotation for Java API 是一個庫,允許您在 Mac、Windows 或 Ubuntu 上向 PDF、Word 和其他文檔添加註釋。 GroupDocs.Annotation for Java 是一個用於管理註釋的原生 Java API,全面支持從圖像和各種其他文檔中創建、添加、編輯、刪除、提取和導出註釋。您可以在此頁面上看到支持的文檔格式的完整列表。 該庫不僅允許您處理 VSD 文檔,還可以處理許多其他類型的文檔,例如 Word、Excel、PowerPoint、Outlook 電子郵件、Visio、Adobe、OpenDocument、OpenOffice、Photoshop、AutoCad 等。 GroupDocs.Annotation for Java API 允許您創建和添加新註釋、編輯註釋、提取註釋、註釋以及從文檔中刪除它們。該庫支持13 種不同的註釋類型,包括文本、折線、區域、下劃線、點、水印、箭頭、橢圓、文本替換、距離、文本字段、PDF、HTML、Microsoft Word 文檔、電子表格、圖表、演示文稿中的資源編輯,繪圖、圖像和許多其他文件格式。 該示例(請參見下文)演示瞭如何使用 VSD 文檔,在此示例中您可以看到如何使用 GroupDocs 的主要步驟。註釋:設置許可證、打開要使用的文檔、創建註釋,根據需要添加數據對象設置註釋屬性,並將結果保存到需要的地方。您還可以在我們的 github 頁面 或我們的產品 文檔

在 Java 中向 VSD 添加註釋的步驟

GroupDocs.Annotation 通過實施幾個簡單的步驟,Java 開發人員可以輕鬆地將各種註釋類型添加到任何基於 Java 的應用程序中的 VSD 文件。

  • 創建帶有評論和日期的 Reply 對象。
  • 創建 AreaAnnotation 對象,設置區域選項並添加回复。
  • 創建 Annotator 對象並添加區域註釋。
  • 保存輸出文件。

系統要求

所有主要平台和操作系統都支持 Java API 的 GroupDocs.Annotation。在執行下面的代碼之前,請確保您的系統上安裝了以下先決條件。

  • 操作系統:Microsoft Windows、Linux、MacOS
  • 開發環境:NetBeans、Intellij IDEA、Eclipse等
  • Java 運行時環境:Java 7 (1.7) 及更高版本
  • GroupDocs Artifact Repository 獲取最新版本的 GroupDocs.Annotation for Java

註釋預覽和代碼示例

// Create an instance of Reply class and add comments
Reply firstReply = new Reply();
firstReply.setComment("First comment");
firstReply.setRepliedOn(Calendar.getInstance().getTime());

Reply secondReply = new Reply();
secondReply.setComment("Second comment");
secondReply.setRepliedOn(Calendar.getInstance().getTime());

List<Reply> replies = new ArrayList<Reply>();
replies.add(firstReply);
replies.add(secondReply);

// Create an instance of AreaAnnotation class and set options
AreaAnnotation area = new AreaAnnotation();
area.setBackgroundColor(65535);
area.setBox(new Rectangle(100, 100, 100, 100));
area.setCreatedOn(Calendar.getInstance().getTime());
area.setMessage("This is area annotation");
area.setOpacity(0.7);
area.setPageNumber(0);
area.setPenColor(65535);
area.setPenStyle(PenStyle.Dot);
area.setPenWidth((byte) 3);
area.setReplies(replies);

// Create an instance of Annotator class
Annotator annotator = new Annotator("input.bmp");

// Add annotation
annotator.add(area);

// Save to file
annotator.save("output.bmp");
annotator.dispose();

Annotation preview image

在 Java 中從 VSD 中刪除註釋的步驟

GroupDocs.Annotation 通過實施幾個簡單的步驟,Java 開發人員可以更輕鬆地從任何基於 Java 的應用程序中的 VSD 文件中刪除註釋詳細信息。

  • 創建帶有評論和日期的 Reply 對象。
  • 實例化 SaveOptions 對象並設置 AnnotationTypes = AnnotationType.None。
  • 使用生成的文檔路徑或流以及 SaveOptions 對象調用 save 方法。

// Create an instance of Annotator class 
Annotator annotator = new Annotator("C://input.bmp");

// Remove annotation by set type None 
SaveOptions saveOptions = new SaveOptions();
saveOptions.setAnnotationTypes(AnnotationType.None);

// Save annotation to output file
annotator.save("C://output.bmp", saveOptions);
annotator.dispose();

在 Java 中編輯 VSD 註釋的步驟

GroupDocs.Annotation 通過實施幾個簡單的步驟,Java 開發人員可以更輕鬆地從任何基於 Java 的應用程序中的 VSD 文件更新各種註釋屬性。

  • 使用輸入文檔路徑或流實例化 Annotator 對象,並使用 ImportAnnotations = true 實例化 LoadOptions。
  • 創建一些 AnnotationBase 實現並設置現有註釋的 Id(如果未找到具有該 Id 的註釋,則不會更改任何內容)或註釋的路徑列表(所有現有註釋將被刪除)。
  • 使用傳遞的註釋調用 Annotator 對象的更新方法。
  • 使用生成的文檔路徑或流以及 SaveOptions 對象調用 save 方法。

String outputPath = "UpdateAnnotation.bmp";

// Create an instance of Annotator class
Annotator annotator = new Annotator("input.bmp");

// Create an instance of Reply class for first example and add comments
Reply reply1 = new Reply();
reply1.setComment("Original first comment");
reply1.setRepliedOn(Calendar.getInstance().getTime());

Reply reply2 = new Reply();
reply2.setComment("Original second comment");
reply2.setRepliedOn(Calendar.getInstance().getTime());

java.util.List replies = new ArrayList();
replies.add(reply1);
replies.add(reply2);

// Create an instance of AreaAnnotation class and set options
AreaAnnotation original = new AreaAnnotation();
original.setId(1);
original.setBackgroundColor(65535);
original.setBox(new Rectangle(100, 100, 100, 100));
original.setCreatedOn(Calendar.getInstance().getTime());
original.setMessage("This is original annotation");
original.setReplies(replies);

// Add original annotation
annotator.add(original);
annotator.save(outputPath);
annotator.dispose();

LoadOptions loadOptions = new LoadOptions();

// Open annotated document
Annotator annotator1 = new Annotator(outputPath, loadOptions);

// Create an instance of Reply class for update first example
Reply reply3 = new Reply();
reply3.setComment("Updated first comment");
reply3.setRepliedOn(Calendar.getInstance().getTime());

Reply reply4 = new Reply();
reply4.setComment("Updated second comment");
reply4.setRepliedOn(Calendar.getInstance().getTime());

java.util.List replies1 = new ArrayList();
replies1.add(reply3);
replies1.add(reply4);

// Suggest we want change some properties of existed annotation
AreaAnnotation updated = new AreaAnnotation();
updated.setId(1);
updated.setBackgroundColor(255);
updated.setBox(new Rectangle(0, 0, 50, 200));
updated.setCreatedOn(Calendar.getInstance().getTime());
updated.setMessage("This is updated annotation");
updated.setReplies(replies1);

// Update and save annotation
annotator1.update(updated);
annotator1.save(outputPath);
annotator1.dispose();

在 Java 中從 VSD 提取註釋的步驟

GroupDocs.Annotation 通過實施幾個簡單的步驟,Java 開發人員可以輕鬆地對文檔進行註釋並從任何基於 Java 的應用程序中的 VSD 文件中提取註釋信息。

  • 創建帶有評論和日期的 Reply 對象。
  • 實例化 LoadOptions 對象並使用 true 參數調用 SetImportAnnotations。
  • 定義類型為 List 的變量。
  • 調用 get 方法並將結果返回到上面的變量。

// For using this example input file ("annotated.bmp") must be with annotations
LoadOptions loadOptions = new LoadOptions();

// Create an instance of Annotator class and get annotations
final Annotator annotator = new Annotator("annotated.bmp", loadOptions);
List annotations = annotator.get();

現場演示添加、刪除、編輯、提取文檔和圖像的註釋

立即訪問 GroupDocs.Annotation 現場演示 網站,向 VSD 文件添加、刪除、編輯和提取註釋。 現場演示有以下好處

無需下載API

無需編寫任何代碼

只需上傳源文件即可

獲取下載鏈接以保存文件

關於 VSD 文件格式

VSD 文件是使用 Microsoft Visio 應用程序創建的圖形,用於表示各種圖形對像以及它們之間的互連。此類繪圖可以包含視覺對象,例如視覺對象、流程圖、UML圖、信息流、組織圖、軟件圖、網絡佈局、數據庫模型、對象映射和其他類似信息。 Microsoft Visio 提供將 Visio 文件轉換為多種不同文件格式的功能,包括 PNG、BMP、PDF 等。

閱讀更多 關於 VSD 文件格式

使用其他流行的文檔格式

更新一些流行文件格式的註釋屬性,如下所述。

Annotate PDF document

(Adobe Portable Document Format)

Annotate DOC document

(Microsoft Word Document)

Annotate DOCM document

(Microsoft Word Macro-Enabled Document)

Annotate DOCX document

(Microsoft Word Open XML Document)

Annotate DOT document

(Microsoft Word Document Template)

Annotate DOTX document

(Word Open XML Document Template)

Annotate RTF document

(Rich Text Document)

Annotate ODT document

(Open Document Text)

Annotate XLS document

(Microsoft Excel Binary File Format)

Annotate XLSX document

(Microsoft Excel Open XML Spreadsheet)

Annotate XLSM document

(Microsoft Excel Macro-Enabled Spreadsheet)

Annotate XLSB document

(Microsoft Excel Binary Worksheet)

Annotate ODS document

(Open Document Spreadsheet)

Annotate PPT document

(PowerPoint Presentation)

Annotate PPTX document

(PowerPoint Open XML Presentation)

Annotate PPSX document

(PowerPoint Open XML Slide Show)

Annotate POTM document

(Microsoft PowerPoint Template)

Annotate PPTM document

(Microsoft PowerPoint Presentation)

Annotate PPS document

(Microsoft PowerPoint 97-2003 Slide Show)

Annotate ODP document

(OpenDocument Presentation)

Annotate HTML document

(HyperText Markup Language)

Annotate TIFF document

(Tagged Image File Format)

Annotate PNG document

(Portable Network Graphic)

Annotate EML document

(E-mail Message)

Annotate MSG document

(Microsoft Outlook E-mail Message)

Annotate VSD document

(Microsoft Visio 2003-2010 Drawing)

Annotate VSDX document

(Microsoft Visio Drawing)

Annotate VSS document

(Microsoft Visio 2003-2010 Stencil)

Annotate VST document

(Microsoft Visio 2013 Stencil)

Annotate DWG document

(Autodesk Design Data Formats)

Annotate DXF document

(AutoCAD Drawing Interchange)

Annotate DCM document

(Digital Imaging and Communications in Medicine)

Annotate WMF document

(Windows Metafile)

Annotate EMF document

(Enhanced Metafile Format)

Back to top
 中文(繁體)