Skip to main content

Crate ofd_core

Crate ofd_core 

Source
Expand description

ofd-core:OFD(开放版式文档,GB/T 33190—2016)基础结构解析库。

本 crate 实现规范第 6 章(容器方案)与第 7 章(基本结构)的解析, 提供从 ZIP 容器到数据模型的标准 Rust API:

  • types:基础数据类型(7.3),如 StBoxStLoc 等;
  • OfdPackage:ZIP 容器读取(第 6 章);
  • modelOFD.xmlDocument.xml、页树/页对象、资源等数据模型;
  • OfdReader:在容器与数据模型之上的高层接口,自动处理路径解析与装载。

§示例

use ofd_core::OfdReader;

let mut reader = OfdReader::open("sample.ofd")?;
println!("版本: {}, 类型: {}", reader.ofd().version, reader.ofd().doc_type);

// 装载第一个版式文档及其首页
let bodies = reader.ofd().doc_bodies.clone();
let doc = reader.load_document(&bodies[0])?;
for page_ref in doc.pages() {
    let page = reader.load_page(&doc, page_ref)?;
    println!("页 {} 是否空白: {}", page_ref.id, page.is_blank());
}

Re-exports§

pub use error::OfdError;
pub use error::Result;
pub use package::OfdPackage;
pub use render::RenderOptions;
pub use types::StArray;
pub use types::StBox;
pub use types::StId;
pub use types::StLoc;
pub use types::StPos;
pub use types::StRefId;
pub use types::parent_dir;
pub use types::resolve_path;
pub use verify::CheckMethod;
pub use verify::CheckReport;
pub use verify::LoadedSignature;
pub use verify::RefStatus;
pub use verify::SigVerdict;
pub use verify::SignatureReport;
pub use verify::check_path;
pub use verify::check_reader;
pub use xmlfmt::pretty_xml;
pub use model::*;

Modules§

crypto
杂凑算法与编码工具(供签名完整性校验使用)。
error
错误类型定义。
model
OFD 基础结构的 XML 数据模型(见 GB/T 33190—2016 第 7 章)。
package
OFD 容器方案(见 GB/T 33190—2016 第 6 章)。
render
OFD → 图片渲染(光栅化)。
types
基础数据类型(见 GB/T 33190—2016 7.3 表 2)。
verify
OFD 规范符合性校验与数字签名完整性校验(见 GB/T 33190—2016 第 7、18 章)。
xmlfmt
XML 美化(重排格式)。

Structs§

LoadedDocument
已装载的版式文档及其在包内的所在目录。
OfdReader
OFD 文档的高层读取器。

Constants§

ENTRY_OFD
包内主入口文件名(见表 1)。