public int convert2Ofd(int imagefileid, String filename,String docdcsurl) { writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------start"); //String docdcsurl = Util.null2String(getPropValue("yzDcsUrl", "docdcsurl")); writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------imagefileid=" + imagefileid + ";filename=" + filename + ";docdcsurl=" + docdcsurl); int newimagefileid = -1; try { if (imagefileid > 0 && !"".equals(filename) && !"".equals(docdcsurl)) { String fileext = ""; if (filename.indexOf(".") != -1) { fileext = filename.substring(filename.lastIndexOf(".")); } writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------fileext=" + fileext); String sourcefilepath = getImageFile(imagefileid + ""); writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------sourcefilepath=" + sourcefilepath); if (!"".equals(sourcefilepath)) { String dcsurl = convert(docdcsurl, sourcefilepath, "29"); writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------dcsurl=" + dcsurl); if (!"".equals(dcsurl)) { InputStream input = getInputStreamFromDcs(dcsurl); writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------input=" + input); String newfilename = filename.substring(0, filename.lastIndexOf(".")) + ".ofd"; if (input != null) { newimagefileid = savePdfImageFile(input, newfilename); } if (new File(sourcefilepath).exists() && new File(sourcefilepath).isFile()) { new File(sourcefilepath).delete(); } } } } } catch (Exception e) { writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------Exception=" + e); } writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------newimagefileid=" + newimagefileid); writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------end"); return newimagefileid; } 加下注释
时间: 2023-08-25 08:12:45 浏览: 128
这是一段 Java 代码,主要用于将指定的图片文件转换成 OFD 格式,并保存为新的文件。具体来说,代码首先接收三个参数:imagefileid 表示图片文件在数据库中的 ID,filename 表示图片文件的名称,docdcsurl 表示 DCS 服务器的 URL 地址。
接着,代码通过 getImageFile 方法获取图片文件的路径,并根据文件扩展名判断图片格式。然后,代码调用 convert 方法将图片文件上传到 DCS 服务器进行转换,并获取转换后文件的 URL 地址。如果转换成功,代码通过 getInputStreamFromDcs 方法从 DCS 服务器下载转换后的文件,并将其保存为新的 OFD 文件。
最后,代码返回新文件在数据库中的 ID(newimagefileid),并在删除原始文件后结束执行。
此代码中的注释主要对各个方法和变量进行了解释和说明,方便其他开发者理解代码逻辑。
相关问题
if (!"".equals(dcsurl)) { InputStream input = getInputStreamFromDcs(dcsurl); writeLog("ConvertToPdfForDcsE9--convertUot2Ofd-------------------input=" + input); String newfilename = filename.substring(0, filename.lastIndexOf(".")) + ".ofd"; if (input != null) { newimagefileid = savePdfImageFile(input, newfilename); } if (new File(sourcefilepath).exists() && new File(sourcefilepath).isFile()) { new File(sourcefilepath).delete(); } } 报这个错 但是 协议不一定用哪个应该怎么改ConvertToPdfForDcsE9--convertUot2Ofd-------------------Exception=java.net.MalformedURLException: no protocol:
这个错误提示表明在使用`new URL(String)`方法时,传入的URL字符串不包含协议信息,即没有以"http://"或"https://"等开头。你需要检查`dcsurl`变量的值是否包含了协议信息,如果没有,可以手动添加协议信息再创建URL对象,例如使用`new URL("http://" + dcsurl)`。另外,如果你不确定`dcsurl`的协议,可以通过判断字符串开头来自动添加协议信息,例如:```
if (!dcsurl.startsWith("http://") && !dcsurl.startsWith("https://")) {
dcsurl = "http://" + dcsurl;
}
```
ofdrw-converter
### 回答1:
OFD-RW Converter是一个多功能的OFD文件转换工具。OFD全称为"开放式文档格式",是由中国电子出版社推出的一种新的电子文档标准,具有高端稳定性、良好的可扩展性和高效的压缩性能等优点。OFD-RW Converter能够将其他格式的文档,如PDF、Word、Excel、图片等,转化成OFD格式,也可以将OFD文件转为其他格式,使文件格式之间的转换更为方便和快捷。此外,OFD-RW Converter还支持批量转换与超级压缩技术,可以大幅缩小转换后文件的大小,节省存储空间。OFD-RW Converter提供丰富的自定义设置,如设置页面大小、边界、纸张方向、书写方向等,以及添加水印、数字签名等功能,使得用户可以更加灵活地进行转换并增加文档的安全性。OFD-RW Converter适用于广泛的场景,如出版、印刷、档案管理、文化传承等。OFD-RW Converter是OFD文件转换的一站式解决方案,为用户提供高效、精确、稳定的文件转换服务。
### 回答2:
OFD是一种新型的电子文档格式,具有优秀的跨平台兼容性和数据保护性能。OFDRW-Converter是一款基于Java语言开发,用于转换并创建OFD文档的工具。该工具提供了丰富的API,可以通过调用相关的数据结构和方法,实现对OFD文档的全面管理和编辑。OFDRW-Converter可以将多种格式的文件转换为OFD文档,例如Word、PDF、图片等等,同时也可以将OFD文档转换为其他格式文件。
OFDRW-Converter工具易于使用、功能强大。它支持OFD的基本元素,如文字、图片、表格等,并且可以用于设计和创建复杂的文档,例如合同、报告、手册等等。OFDRW-Converter还提供了多种导出OFD文档的方式,可选择打印、预览、保存至本地磁盘或在线服务等。与此同时,该工具的源代码是公开的,方便开发者进行二次开发和个性化定制。
总而言之,OFDRW-Converter是一款可以帮助用户有效地创建、编辑和管理OFD文档的有力工具。它为OFD格式的使用和推广提供了更加便利和可靠的支持,有助于提高中国电子文档的国际影响力。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)