public class OFDReader extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected ResourceLocator |
rl
资源定位器
|
| Constructor and Description |
|---|
OFDReader(InputStream stream)
构造一个 OFDReader
|
OFDReader(Path ofdFile)
构造一个 OFDReader
|
OFDReader(String ofdFileLoc)
构造一个 OFDReader
|
OFDReader(String unzippedPathRoot,
boolean deleteOnClose)
因一些ofd文件无法使用ZipUtil解压缩,可以让用户自己在外面解压缩好后,传入根目录创建
例如用户可以使用unzip或者unar等命令行方式解压缩,因此通过参数控制是否删除目录。
|
protected ResourceLocator rl
解析路径获取资源
public OFDReader(Path ofdFile) throws IOException
ofdFile - OFD文件IOException - OFD文件操作IO异常public OFDReader(String ofdFileLoc) throws IOException
ofdFileLoc - OFD文件位置,例如:”/home/user/myofd.ofd“IOException - OFD文件操作IO异常public OFDReader(InputStream stream) throws IOException
stream - OFD文件输入流,流由调用者负责关闭。IOException - OFD文件操作IO异常public OFDReader(String unzippedPathRoot, boolean deleteOnClose)
unzippedPathRoot - 已经解压的OFD根目录位置deleteOnClose - 退出时是否删除 unzippedPathRoot 文件, true - 退出时删除;false - 不删除public Path getWorkDir()
@Deprecated public static void setZipFileMaxSize(long size)
默认值: 100MB
size - 解压文件大小,单位字节(Byte)public OFDDir getOFDDir()
public ST_Loc getDefaultDocSignaturesPath()
BadOFDException - 错误OFD结构和文件格式导致结构无法解析public Signatures getDefaultSignatures()
如果文件不存在则返还null
public boolean hasSignature()
public Annotations getAnnotations()
如果文档中没有注释文件,那么返还null
public int getNumberOfPages()
public PageInfo getPageInfo(int pageNum)
pageNum - 页码,从1开始public TemplatePageEntity getTemplate(String id)
id - 模板IDpublic Document cdDoc(int numOfDoc) throws org.dom4j.DocumentException, FileNotFoundException
该操作将会导致资源加载器变更目录
如果需要恢复被切换的目录请主动在外部调用restore
numOfDoc - 文档序号org.dom4j.DocumentException - 文档解析异常FileNotFoundException - Document.xml文档不存在public Document getDoc(int numOfDoc) throws org.dom4j.DocumentException, FileNotFoundException
numOfDoc - 文档序号org.dom4j.DocumentException - 文档解析异常FileNotFoundException - Document.xml文档不存在public Document cdDefaultDoc() throws org.dom4j.DocumentException, FileNotFoundException
该操作将会导致资源加载器变更目录
如果需要恢复被切换的目录请主动在外部调用restore
org.dom4j.DocumentException - 文档解析异常FileNotFoundException - Document.xml文档不存在public ST_Box getPageSize(Page page)
如果页面没有定义页面区域,则使用文件 CommonData中的定义
page - 页面对象,null 表示获取默认物理页面大小。public CT_PageArea getPageArea(int num)
num - 页码,从1起,若页码存在或超过最大最小页码则返还默认页面区域。public ST_Box getPageSize(int num)
num - 页码,从1起,当页码不存在时返回文档中的默认 页面物理大小。public CT_PageArea getPageArea(Page page)
page - 页面对象,若为null 则返回文档默认页面区域大小。public Page getPage(int pageNum)
pageNum - 页码,从1起NumberFormatException - 页码小于1RuntimeException - 路径不存在,或文档解析异常public ST_Loc getPageAbsLoc(int pageNum)
pageNum - 页码NumberFormatException - 页码小于1RuntimeException - 路径不存在public ST_ID getPageObjectId(int pageNum)
pageNum - 页码public ResourceLocator getResourceLocator()
public List<CT_Attachment> getAttachmentList()
注意该对象均为只读
BadOFDException - 文档结构损坏public Path getAttachmentFile(CT_Attachment attachment)
注意:该文件会在Close Reader时候被删除,请在之前复制到其他地方
attachment - 附件信息public CT_Attachment getAttachment(String name)
该方法不会恢复资源定位器
name - 附件名称public Path getAttachmentFile(String name)
注意:该文件会在Close Reader时候被删除,请在之前复制到其他地方
name - 附件名称public List<StampAnnotEntity> getStampAnnots()
public List<AnnotionEntity> getAnnotationEntities()
public ResourceManage getResMgt()
资源管理器获取到的对象均为只读对象
public static void setNamespaceStrictMode(boolean enable)
启用严格模式后将会忽略非ofd命名空间的元素。
默认:关闭严格模式
enable - true - 启用; false - 兼容模式(默认),兼容ofd命名空间public void close()
throws IOException
删除工作区
close in interface Closeableclose in interface AutoCloseableIOException - 工作区删除异常Copyright © 2026. All rights reserved.