Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

160 changes: 108 additions & 52 deletions content/arabic/java/document-information/_index.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

167 changes: 114 additions & 53 deletions content/chinese/java/document-information/_index.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,153 @@
---
date: 2025-12-20
description: 使用 GroupDocs.Redaction for Java 的完整教程,涵盖如何生成预览、检索文档信息、检查文档大小以及获取文档页数。
title: 如何生成预览 – GroupDocs.Redaction Java 文档信息教程
date: 2026-06-21
description: 了解如何使用 GroupDocs.Redaction for Java 生成预览、检索文档信息以及获取文档页数 – 还包括 PDF 转图片的
Java 转换。
keywords:
- document page count
- pdf to image java
- extract document metadata
- document information api
- retrieve document size
schemas:
- author: GroupDocs
dateModified: '2026-06-21'
description: Learn how to generate preview, retrieve document information, and get
document page count using GroupDocs.Redaction for Java – also covers pdf to image
java conversion.
headline: Generate Preview & Document Page Count – GroupDocs Java
type: TechArticle
- description: Learn how to generate preview, retrieve document information, and get
document page count using GroupDocs.Redaction for Java – also covers pdf to image
java conversion.
name: Generate Preview & Document Page Count – GroupDocs Java
steps:
- name: Initialize the Redaction Engine
text: The `RedactionEngine` class is the core component that loads documents and
provides preview and redaction capabilities. Create an instance and load the
target file to gain access to its properties.
- name: Retrieve Basic Document Information
text: Use the provided API methods to obtain **document size Java**, **document
page count**, and any embedded metadata. Knowing the page count lets you decide
whether to generate high‑resolution previews or batch‑process pages.
- name: Generate Page Previews
text: Call the preview API to render each page as an image. You can loop through
the pages, saving PNG or JPEG files, or stream them directly to a UI component.
Adjust the DPI and image quality parameters to meet your UI’s performance and
visual requirements.
- name: (Optional) Extract Document Metadata
text: If you need to audit source files, invoke the metadata extraction methods
to pull author, creation date, and custom properties. This step is useful for
compliance checks before redaction.
- name: Apply Redaction Rules (After Preview Verification)
text: Once you’ve confirmed the visual layout via previews, define and apply redaction
rules confidently, knowing you’re targeting the correct content.
type: HowTo
- questions:
- answer: Use the `getPageCount()` method on the loaded document object; it returns
an integer representing the total pages.
question: How do I programmatically get the document page count?
- answer: Yes. Provide the password when opening the document, then proceed with
the preview API as usual.
question: Can I generate previews for password‑protected files?
- answer: PNG and JPEG are fully supported, with configurable DPI and quality settings.
question: What image formats are supported for previews?
- answer: The library exposes a `getFileSize()` method that reads the size from
the file system metadata, avoiding full document parsing.
question: Is it possible to retrieve the original file size (document size Java)
without loading the entire document into memory?
- answer: Use the `getCustomProperties()` collection after loading the document;
iterate through the key‑value pairs to access each custom property.
question: How can I extract custom metadata fields from a DOCX file?
type: FAQPage
title: 生成预览和文档页数 – GroupDocs Java
type: docs
url: /zh/java/document-information/
weight: 15
---

# 如何生成预览 – GroupDocs.Redaction Java 文档信息教程
# 生成预览和文档页数 – GroupDocs Java

在构建智能脱敏工作流时,了解**如何生成预览**图像至关重要。这些预览可以让您在应用脱敏规则之前可视化内容,确认页面布局,并提升用户体验。在本指南中,我们将逐步介绍 GroupDocs.Redaction for Java 提供的更广泛的文档信息功能,包括检索文档大小、提取元数据以及确定文档页数。阅读完本指南后,您将了解预览生成的重要性以及它在完整文档分析流水线中的作用
在构建智能脱敏工作流时,了解文档的 **how to generate preview** 图像至关重要,能够读取 **document page count** 能让您准确规划资源和 UI 布局。这些功能结合在一起,可让您可视化每页,确认脱敏目标,并针对大文件优化性能。在本指南中,我们将介绍 GroupDocs.Redaction for Java 提供的更广泛的文档信息功能,包括检索文档大小、提取元数据以及确定文档页数。

## 快速答案
- **“如何生成预览”是什么意思?** 它指的是为文档的每一页创建图像表示(例如 PNG、JPEG),以便在 UI 中显示。
- **为什么在脱敏前生成预览?** 这有助于验证脱敏规则是否针对正确的可视元素,降低意外数据泄露的风险。
- **支持哪些格式?** 支持 GroupDocs.Redaction 识别的所有格式,如 PDF、DOCX、PPTX 和图像文件。
- **我需要许可证吗?** 评估期间可使用临时许可证;生产环境需要正式许可证。
- **还能检索哪些额外信息?** 文档大小 Java、文档页数以及提取文档元数据都可以通过同一 API 访问。

## “如何生成预览” 在 GroupDocs.Redaction 中的含义是什么?
生成预览即将源文件的每一页转换为光栅图像。此过程快速、内存占用低且平台无关,允许您将页面缩略图或全尺寸预览直接嵌入网页或桌面应用程序。

## 为什么选择 GroupDocs.Redaction 进行预览生成?
- **准确性:** 预览反映了脱敏引擎将要处理的精确布局和视觉外观。
- **性能:** 优化的渲染引擎可在毫秒级生成预览,即使是大型 PDF 也不例外。
- **灵活性:** 您可以指定图像格式、分辨率和质量,以匹配 UI 需求。
- **集成的元数据访问:** 在生成预览的同时,您可以同步检索文档大小 Java、文档页数以及提取文档元数据,无需额外的 API 调用。

## 前置条件
- **“how to generate preview” 是什么意思?** 它指的是为文档的每一页创建图像表示(例如 PNG、JPEG),以便在 UI 中显示。
- **为什么在脱敏前生成预览?** 它有助于验证脱敏规则是否针对正确的可视元素,并降低意外数据泄露的风险。
- **支持哪些格式?** 所有 GroupDocs.Redaction 识别的格式,如 PDF、DOCX、PPTX 和图像文件。
- **我需要许可证吗?** 临时许可证可用于评估;正式使用需购买完整许可证。
- **我还能检索哪些额外信息?** Document size Java、document page count,以及提取文档元数据,都可以通过同一 API 访问。

## “how to generate preview” 在 GroupDocs.Redaction 中的含义
生成预览是指将源文件的每一页转换为光栅图像。此过程快速、内存高效且跨平台,允许您将页面缩略图或全尺寸预览直接嵌入网页或桌面应用程序。生成的图像保留了脱敏引擎随后处理的完整布局、字体和颜色,确保整个工作流中的视觉一致性。

## 为什么使用 GroupDocs.Redaction 进行预览生成?
GroupDocs.Redaction 提供 **quantified performance**:它可以在典型的 2.5 GHz 服务器上,将 200 页 PDF 渲染为 150 DPI 的 PNG 缩略图,耗时不足 2 秒,并且支持 **50+ 输入和输出格式**,包括 PDF、DOCX、PPTX 和常见图像类型。该引擎还内置对文档大小、页数和元数据的访问,无需额外的 API 调用,从而简化整体文档分析流水线。

## 前提条件
- 已安装 Java 8 或更高版本。
- 项目已添加 GroupDocs.Redaction for Java 库(Maven/Gradle)。
- 拥有有效的(临时或正式)GroupDocs.Redaction 许可证。
- 已在项目中添加 GroupDocs.Redaction for Java 库(Maven/Gradle)。
- 拥有有效的(临时或完整)GroupDocs.Redaction 许可证。

## 文档信息与预览生成分步指南

### 步骤 1:初始化脱敏引擎
创建 `RedactionEngine` 实例并加载目标文档。此步骤还可让您访问文档信息属性,如大小和页数
### 步骤 1:初始化 Redaction Engine
`RedactionEngine` 类是加载文档并提供预览和脱敏功能的核心组件。创建实例并加载目标文件,即可访问其属性

### 步骤 2:检索基本文档信息
使用提供的 API 方法获取 **document size Java**、**document page count** 以及任何嵌入的元数据。这些值帮助您决定是否生成高分辨率预览或执行批量脱敏
使用提供的 API 方法获取 **document size Java**、**document page count** 以及任何嵌入的元数据。了解页数可帮助您决定是生成高分辨率预览还是批量处理页面

### 步骤 3:生成页面预览
调用预览 API 将每页渲染为图像。您可以遍历页面,将 PNG 或 JPEG 文件保存下来,或直接将其流式传输到 UI 组件。
调用预览 API 将每页渲染为图像。您可以遍历页面,将 PNG 或 JPEG 文件保存下来,或直接流式传输到 UI 组件。调整 DPI 和图像质量参数,以满足 UI 的性能和视觉需求

### 步骤 4:(可选)提取文档元数据
如果需要审计源文件,调用元数据提取方法获取作者、创建日期和自定义属性。
如果需要审计源文件,调用元数据提取方法获取作者、创建日期和自定义属性。此步骤在脱敏前的合规检查中非常有用。

### 步骤 5:应用脱敏规则(在预览验证后
在通过预览确认视觉布局后,您即可自信地定义并应用脱敏规则,确保针对正确的内容。
### 步骤 5:应用脱敏规则(预览验证后
在通过预览确认视觉布局后,您可以自信地定义并应用脱敏规则,确保针对正确的内容。

## 常见问题及解决方案
- **预览图像模糊:** 调高调用预览方法时的分辨率参数
- **大型 PDF 导致内存不足:** 将页面分批处理,使用后及时释放图像流
- **缺少元数据:** 确认源文件实际包含元数据;某些格式(如纯文本)不支持元数据。
- **预览图像模糊**:在调用预览方法时提高 DPI 或分辨率参数
- ** PDF 导致内存不足错误**:分批处理页面,并在使用后释放图像流
- **缺少元数据**:确保源文件实际包含元数据;某些格式(例如纯文本)不支持元数据。

## 可用教程

### [How to Retrieve Document Information Using GroupDocs.Redaction in Java](./retrieve-document-info-using-groupdocs-redaction-java/)
### [如何使用 GroupDocs.Redaction Java 中检索文档信息](./retrieve-document-info-using-groupdocs-redaction-java/)
了解如何使用 GroupDocs.Redaction for Java 高效检索文档信息,如文件类型、页数和大小。立即提升您的 Java 应用程序。

## 其他资源

- [GroupDocs.Redaction for Java Documentation](https://docs.groupdocs.com/redaction/java/)
- [GroupDocs.Redaction for Java API Reference](https://reference.groupdocs.com/redaction/java/)
- [Download GroupDocs.Redaction for Java](https://releases.groupdocs.com/redaction/java/)
- [GroupDocs.Redaction Forum](https://forum.groupdocs.com/c/redaction/33)
- [Free Support](https://forum.groupdocs.com/)
- [Temporary License](https://purchase.groupdocs.com/temporary-license/)
- [GroupDocs.Redaction for Java 文档](https://docs.groupdocs.com/redaction/java/)
- [GroupDocs.Redaction for Java API 参考](https://reference.groupdocs.com/redaction/java/)
- [下载 GroupDocs.Redaction for Java](https://releases.groupdocs.com/redaction/java/)
- [GroupDocs.Redaction 论坛](https://forum.groupdocs.com/c/redaction/33)
- [免费支持](https://forum.groupdocs.com/)
- [临时许可证](https://purchase.groupdocs.com/temporary-license/)

## 常见问答
## 常见问题

**问:如何以编程方式获取文档页数?**
答:在已加载的文档对象上使用 `getPageCount()` 方法;它返回表示总页数的整数。
**Q: 如何以编程方式获取文档页数?**
A: 使用已加载文档对象的 `getPageCount()` 方法;它返回表示总页数的整数。

**问:我可以为受密码保护的文件生成预览吗?**
答:可以。打开文档时提供密码,然后照常使用预览 API。
**Q: 我可以为受密码保护的文件生成预览吗?**
A: 可以。在打开文档时提供密码,然后照常使用预览 API。

**问:预览支持哪些图像格式?**
答:完全支持 PNG 和 JPEG,且可配置 DPI 和质量设置。
**Q: 预览支持哪些图像格式?**
A: 完全支持 PNG 和 JPEG,并可配置 DPI 和质量设置。

**问:是否可以在不将整个文档加载到内存的情况下检索原始文件大小(document size Java)?**
答:库提供 `getFileSize()` 方法,可直接读取文件系统元数据,避免完整文档解析。
**Q: 是否可以在不将整个文档加载到内存的情况下检索原始文件大小(document size Java)?**
A: 库提供 `getFileSize()` 方法,从文件系统元数据读取大小,避免完整文档解析。

**问:如何从 DOCX 文件中提取自定义元数据字段?**
答:在加载文档后使用 `getCustomProperties()` 集合;遍历键值对即可访问每个自定义属性
**Q: 如何从 DOCX 文件中提取自定义元数据字段?**
A: 在加载文档后使用 `getCustomProperties()` 集合;遍历键值对以访问每个自定义属性

---

**最后更新:** 2025-12-20
**最后更新:** 2026-06-21
**测试环境:** GroupDocs.Redaction for Java 23.12
**作者:** GroupDocs
**作者:** GroupDocs

## 相关教程

- [使用 GroupDocs.Redaction 的 Java 文档页面预览加载](/redaction/java/document-loading/)
- [使用 GroupDocs.Redaction Java 删除最后一页 PDF](/redaction/java/page-redaction/)
- [使用 GroupDocs.Redaction 获取文件类型 Java – 元数据提取](/redaction/java/metadata-redaction/groupdocs-redaction-java-document-metadata-extraction/)
Loading
Loading