从 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
 中国人