求Java中cdr预览插件Word,PDF,图片的插件

前台js有没有办法实现附件比如word或者pdf的预览? - CNode技术社区
前台js有没有办法实现附件比如word或者pdf的预览?就是上传了一个附件,鼠标移上去就能显示一个类似tip的页面来显示附件的内容
只显示第一页缩略图也行 因为一般第一页就有文档的标题甚至概要之类的 请问后台产生图片这个有没有好的点子? 我自己查到的有转pdf再转swf的 也有用weboffice的 也听说可以用POI 有没有这方面经验呢?
纯js肯定不行,需要后端生成附件的缩略图。但是只有第一页的缩略图的话,也是没什么意义的……
目前想到就显示第一页缩略图也行
因为一般第一页就有文档的标题甚至概要之类的
请问后台产生图片这个有没有好的点子?
我自己查到的有转pdf再转swf的
也有用weboffice的
也听说可以用POI
有没有这方面经验呢?
如果是windows,并且安装了Office的话,可以用IExtractImage Shell extension来获取。虚拟打印应该也可以,但是效率没这个高。
估计不能用这个
貌似领导要求就需要先转成图片然后前台显示了
目前就愁于怎样在后台把word,pdf之类的编程图片…
我说的就是后台。
有啥好的方案吗?
尽量不依赖windows或者第三方浏览器插件的?
抱歉,只知道这么多了……
这一般都是上传后台处理的,pdf可以看,word文档应该属于xml文件,但专门解析的库没有找到,都是借助插件的。
多谢给了这么多建议~
我再去琢磨琢磨
qq邮箱有 word,pdf (chrome 原生支持)
的在线预览,但是没有采用 类似于 flexpaper 的方案;很好奇
pdf,可以直接用浏览器浏览的
word文档,你可以尝试使用一些富文本编辑器,它们里面可以解析。具体什么名字忘了,一个是国内用的比较广泛的,一个是google的
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
服务器赞助商为
,存储赞助商为
,由提供应用性能服务。
新手搭建 Node.js 服务器,推荐使用无需备案的openoffice装了,服务也开了,swftools也装了,权限也授了,可是访问页面一直在更新,不知道那地方出问题了,大神求助,谢谢。
项目构架:
onlineView.jsp
String&swfFilePath=session.getAttribute(&swfpath&).toString();&&
&script&type=&text/javascript&&src=&&%=basePath%&js/main/jquery.js&&&/script&&&
&script&type=&text/javascript&&src=&&%=basePath%&js/main/flexpaper_flash.js&&&/script&&&
&script&type=&text/javascript&&src=&&%=basePath%&js/main/flexpaper_flash_debug.js&&&/script&&&
&script&type=&text/javascript&&src=&&%=basePath%&js/main/flexpaper.js&&&/script&&&
&&&&&&&&&&&&&script&type=&text/javascript&&&&&
&&&&&&&&&&&&&&&&var&fp&=&new&FlexPaperViewer(&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&'FlexPaperViewer',&&
&&&&&&&&&&&&&&&&&&&&&&&&&'viewerPlaceHolder',&{&config&:&{&&
&&&&&&&&& &&&&&&&&&&&&&&&&SwfFile&:&escape('&%=swfFilePath%&'),&&
&&&&&&&&& &&&&&&&&&&&&&&&Scale&:&0.6,&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&ZoomTransition&:&'easeOut',&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&ZoomTime&:&0.5,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&ZoomInterval&:&0.2,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&FitPageOnLoad&:&true,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&FitWidthOnLoad&:&false,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&FullScreenAsMaxWindow&:&false,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&ProgressiveLoading&:&false,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&MinZoomSize&:&0.2,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&MaxZoomSize&:&5,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&SearchMatchAll&:&false,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&InitViewMode&:&'SinglePage',&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&ViewModeToolsVisible&:&true,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&ZoomToolsVisible&:&true,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&NavToolsVisible&:&true,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&CursorToolsVisible&:&true,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&SearchToolsVisible&:&true,&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&localeChain:&'en_US'&&
&&&&&&&&&&&&&&&&&&&&&&&&&}});&&
&&&&&&&&&&&&&/script&&&&&&&&&&&&&&&
&&&&&&&&&/div&&&
detailKnowledge.jsp
&&&&Knowledge&knowledge=(Knowledge)request.getAttribute(&knowledge&);
String&filename=PropertiesUtil.getProperty(&fileManageUpLoad&)+&/&+knowledge.getFilecode();
//调用转换类DocConverter,并将需要转换的文件传递给该类的构造方法
&&&&OnlineView&d&=&new&OnlineView(filename);
&&&&//调用conver方法开始转换,先执行doc2pdf()将office文件转换为再执行pdf2swf()将pdf转换为&&
&&&&d.conver();
&&&&//调用getswfPath()方法,打印转换后的swf文件路径&&
&&&&System.out.println(d.getswfPath());
&&&&//生成swf相对路径,以便传递给flexpaper播放器
&&&&String&swfpath&=&PropertiesUtil.getProperty(&fileManageUpLoad&)+d.getswfPath().substring(d.getswfPath().lastIndexOf(&/&));
&&&&System.out.println(swfpath);
&&//将相对路径放入sessio中保存
&&&&session.setAttribute(&swfpath&,&swfpath);
&&&&out.println(&&hr&&);
跳转的action
form&name=&viewForm&&id=&form_swf&&action=&&%=basePath%&knowledge/onlineView.html?id=${knowledge.id&}&&method=&POST&&
&&&&&input&type='submit'&value='预览'&class='BUTTON&SUBMIT'/&
controller:
@Controller
@RequestMapping(value=&/knowledge&)
public&class&KnowledgeCtl&{
&&&&&&&@RequestMapping(value=&/onlineView&,method=RequestMethod.POST)
public&ModelAndView&onlineView(@RequestParam(&id&)String&id)
ModelAndView&model=new&ModelAndView(&/equipment/onlineView&);
转换的util:
public&class&OnlineView&{
&&private&static&final&int&environment&=&1;//&环境&1:windows&2:linux
&&&&private&String&fileS//&(只涉及pdf2swf路径问题)&&
&&&&private&String&outputPath&=&&&;//&输入路径&,如果不设置就输出在默认的位置&&
&&&&private&String&fileN&&
&&&&private&File&pdfF&&
&&&&private&File&swfF&&
&&&&private&File&docF&&
&&&&public&OnlineView(String&fileString)&{&&
&&&&&&&&ini(fileString);&&
&&&&&*&重新设置file
&&&&&*&@param&fileString&
&&&&public&void&setFile(String&fileString)&{&&
&&&&&&&&ini(fileString);&&
&&&&&*&初始化&
&&&&&*&@param&fileString&
&&&&private&void&ini(String&fileString)&{&&
&&&&&&&&this.fileString&=&fileS&&
&&&&&&&&fileName&=&fileString.substring(0,&fileString.lastIndexOf(&.&));&&
&&&&&&&&docFile&=&new&File(fileString);&&
&&&&&&&&pdfFile&=&new&File(fileName&+&&.pdf&);&&
&&&&&&&&swfFile&=&new&File(fileName&+&&.swf&);&&
&&&&&*&转为PDF&
&&&&&*&@param&file&
&&&&private&void&doc2pdf()&throws&Exception&{&&
&&&&&&&&if&(docFile.exists())&{&&
&&&&&&&&&&&&if&(!pdfFile.exists())&{&&
&&&&&&&&&&&&&&&&OpenOfficeConnection&connection&=&new&SocketOpenOfficeConnection(8100);&&
&&&&&&&&&&&&&&&&try&{&&
&&&&&&&&&&&&&&&&&&&&connection.connect();&&
&&&&&&&&&&&&&&&&&&&&DocumentConverter&converter&=&new&OpenOfficeDocumentConverter(connection);&&
&&&&&&&&&&&&&&&&&&&&converter.convert(docFile,&pdfFile);&&
&&&&&&&&&&&&&&&&&&&&//&close&the&connection&&
&&&&&&&&&&&&&&&&&&&&connection.disconnect();&&
&&&&&&&&&&&&&&&&&&&&System.out.println(&****pdf转换成功,PDF输出:&&+&pdfFile.getPath()+&&****&);&&
&&&&&&&&&&&&&&&&}&catch&(java.net.ConnectException&e)&{&&
&&&&&&&&&&&&&&&&&&&&e.printStackTrace();&&
&&&&&&&&&&&&&&&&&&&&System.out.println(&****swf转换器异常,openoffice服务未启动!****&);&&
&&&&&&&&&&&&&&&&&&&&throw&e;&&
&&&&&&&&&&&&&&&&}&catch&(com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException&e)&{&&
&&&&&&&&&&&&&&&&&&&&e.printStackTrace();&&
&&&&&&&&&&&&&&&&&&&&System.out.println(&****swf转换器异常,读取转换文件失败****&);&&
&&&&&&&&&&&&&&&&&&&&throw&e;&&
&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{&&
&&&&&&&&&&&&&&&&&&&&e.printStackTrace();&&
&&&&&&&&&&&&&&&&&&&&throw&e;&&
&&&&&&&&&&&&&&&&}&&
&&&&&&&&&&&&}&else&{&&
&&&&&&&&&&&&&&&&System.out.println(&****已经转换为pdf,不需要再进行转化****&);&&
&&&&&&&&&&&&}&&
&&&&&&&&}&else&{&&
&&&&&&&&&&&&System.out.println(&****swf转换器异常,需要转换的文档不存在,无法转换****&);&&
&&&&&&&&}&&
&&&&&*&转换成&swf&
&&&&@SuppressWarnings(&unused&)&&
&&&&private&void&pdf2swf()&throws&Exception&{&&
&&&&&&&&Runtime&r&=&Runtime.getRuntime();&&
&&&&&&&&if&(!swfFile.exists())&{&&
&&&&&&&&&&&&if&(pdfFile.exists())&{&&
&&&&&&&&&&&&&&&&if&(environment&==&1)&{//&windows环境处理&&
&&&&&&&&&&&&&&&&&&&&try&{&&
&&&&&&&&&&&&&&&&&&&&&&&&Process&p&=&r.exec(&E:/swftoolsf2swf.exe&&+&pdfFile.getPath()&+&&&-o&&+&swfFile.getPath()&+&&&-T&9&);&&
&&&&&&&&&&&&&&&&&&&&&&&&System.out.print(loadStream(p.getInputStream()));&&
&&&&&&&&&&&&&&&&&&&&&&&&System.err.print(loadStream(p.getErrorStream()));&&
&&&&&&&&&&&&&&&&&&&&&&&&System.out.print(loadStream(p.getInputStream()));&&
&&&&&&&&&&&&&&&&&&&&&&&&System.err.println(&****swf转换成功,文件输出:&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&+&swfFile.getPath()&+&&****&);&&
&&&&&&&&&&&&&&&&&&&&&&&&if&(pdfFile.exists())&{&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&pdfFile.delete();&&
&&&&&&&&&&&&&&&&&&&&&&&&}&&
&&&&&&&&&&&&&&&&&&&&}&catch&(IOException&e)&{&&
&&&&&&&&&&&&&&&&&&&&&&&&e.printStackTrace();&&
&&&&&&&&&&&&&&&&&&&&&&&&throw&e;&&
&&&&&&&&&&&&&&&&&&&&}&&
&&&&&&&&&&&&&&&&}&else&if&(environment&==&2)&{//&linux环境处理&&
&&&&&&&&&&&&&&&&&&&&try&{&&
&&&&&&&&&&&&&&&&&&&&&&&&Process&p&=&r.exec(&pdf2swf&&&+&pdfFile.getPath()&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&+&&&-o&&&+&swfFile.getPath()&+&&&-T&9&);&&
&&&&&&&&&&&&&&&&&&&&&&&&System.out.print(loadStream(p.getInputStream()));&&
&&&&&&&&&&&&&&&&&&&&&&&&System.err.print(loadStream(p.getErrorStream()));&&
&&&&&&&&&&&&&&&&&&&&&&&&System.err.println(&****swf转换成功,文件输出:&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&+&swfFile.getPath()&+&&****&);&&
&&&&&&&&&&&&&&&&&&&&&&&&if&(pdfFile.exists())&{&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&pdfFile.delete();&&
&&&&&&&&&&&&&&&&&&&&&&&&}&&
&&&&&&&&&&&&&&&&&&&&}&catch&(Exception&e)&{&&
&&&&&&&&&&&&&&&&&&&&&&&&e.printStackTrace();&&
&&&&&&&&&&&&&&&&&&&&&&&&throw&e;&&
&&&&&&&&&&&&&&&&&&&&}&&
&&&&&&&&&&&&&&&&}&&
&&&&&&&&&&&&}&else&{&&
&&&&&&&&&&&&&&&&System.out.println(&****pdf不存在,无法转换****&);&&
&&&&&&&&&&&&}&&
&&&&&&&&}&else&{&&
&&&&&&&&&&&&System.out.println(&****swf已经存在不需要转换****&);&&
&&&&&&&&}&&
&&&public&&static&String&loadStream(InputStream&in)&throws&IOException&{&&
&&&&&&&&int&ptr&=&0;&&
&&&&&&&&in&=&new&BufferedInputStream(in);&&
&&&&&&&&StringBuffer&buffer&=&new&StringBuffer();&&
&&&&&&&&while&((ptr&=&in.read())&!=&-1)&{&&
&&&&&&&&&&&&buffer.append((char)&ptr);&&
&&&&&&&&}&&
&&&&&&&&return&buffer.toString();&&
&&&&&*&转换主方法&
&&&&@SuppressWarnings(&unused&)&&
&&&&public&boolean&conver()&{&&
&&&&&&&&if&(swfFile.exists())&{&&
&&&&&&&&&&&&System.out.println(&****swf转换器开始工作,该文件已经转换为swf****&);&&
&&&&&&&&&&&&return&&&
&&&&&&&&}&&
&&&&&&&&if&(environment&==&1)&{&&
&&&&&&&&&&&&System.out.println(&****swf转换器开始工作,当前设置运行环境windows****&);&&
&&&&&&&&}&else&{&&
&&&&&&&&&&&&System.out.println(&****swf转换器开始工作,当前设置运行环境linux****&);&&
&&&&&&&&}&&
&&&&&&&&try&{&&
&&&&&&&&&&&&doc2pdf();&&
&&&&&&&&&&&&pdf2swf();&&
&&&&&&&&}&catch&(Exception&e)&{&&
&&&&&&&&&&&&e.printStackTrace();&&
&&&&&&&&&&&&return&&&
&&&&&&&&}&&
&&&&&&&&if&(swfFile.exists())&{&&
&&&&&&&&&&&&return&&&
&&&&&&&&}&else&{&&
&&&&&&&&&&&&return&&&
&&&&&&&&}&&
&&&&&*&返回文件路径&
&&&&&*&@param&s&
&&&&public&String&getswfPath()&{&&
&&&&&&&&if&(swfFile.exists())&{&&
&&&&&&&&&&&&String&tempString&=&swfFile.getPath();&&
&&&&&&&&&&&&tempString&=&tempString.replaceAll(&\\\\&,&&/&);&&
&&&&&&&&&&&&return&tempS&&
&&&&&&&&}&else&{&&
&&&&&&&&&&&&return&&&;&&
&&&&&&&&}&&
&&&&&*&设置输出路径&
&&&&public&void&setOutputPath(String&outputPath)&{&&
&&&&&&&&this.outputPath&=&outputP&&
&&&&&&&&if&(!outputPath.equals(&&))&{&&
&&&&&&&&&&&&String&realName&=&fileName.substring(fileName.lastIndexOf(&/&),&&
&&&&&&&&&&&&&&&&&&&&fileName.lastIndexOf(&.&));&&
&&&&&&&&&&&&if&(outputPath.charAt(outputPath.length())&==&'/')&{&&
&&&&&&&&&&&&&&&&swfFile&=&new&File(outputPath&+&realName&+&&.swf&);&&
&&&&&&&&&&&&}&else&{&&
&&&&&&&&&&&&&&&&swfFile&=&new&File(outputPath&+&realName&+&&.swf&);&&
&&&&&&&&&&&&}&&
&&&&&&&&}&&
回复讨论(解决方案)
先确定是转换的有问题,还是查看有问题。
一步一步调试一下就好了。
确定文件有没有转换成功,二确定openoffice有没有获取到你转换好的文件
转换没有问题,在后台有相应的输出文件,也没有报错信息,就是一直在刷新的状态
把那个flash放根目录试试
放到根目录是404,他访问的的目录是knowledge下的,所以必须放在那个目录
直接去openoffice官网论坛找support解决吧。
________________
onlineView.jsp&的js最后添加
&&swfobject.embedSWF(&knowledge/FlexPaperViewer.swf&,&cb&,&500&,&500&,&9.0.0&,&knowledge/expressInstall.swf&,&fp);
只支持xls文件预览1170人阅读
在页面上显示各种文档中的内容。在servlet中的逻辑
BufferedInputStream bis =
& URL url =
& HttpURLConnection httpUrl = // 建立链接
& url = new URL(urlReal);
& httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
& httpUrl.connect();// 获取网络输入流
& bis = new BufferedInputStream(httpUrl.getInputStream());
& String bodyText =
& WordExtractor ex = new WordExtractor(bis);
& bodyText = ex.getText();
& response.getWriter().write(bodyText);
BufferedInputStream bis =
& URL url =
& HttpURLConnection httpUrl = // 建立链接
& url = new URL(urlReal);
& httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
& httpUrl.connect();// 获取网络输入流
& bis = new BufferedInputStream(httpUrl.getInputStream());&
content = new StringBuffer();
& HSSFWorkbook workbook = new HSSFWorkbook(bis);
& for (int numSheets = 0; numSheets & workbook.getNumberOfSheets(); numSheets++) {
&& HSSFSheet aSheet = workbook.getSheetAt(numSheets);// 获得一个sheet
&& content.append(&/n&);
&& if (null == aSheet) {
&& for (int rowNum = 0; rowNum &= aSheet.getLastRowNum(); rowNum++) {
&&& content.append(&/n&);
&&& HSSFRow aRow = aSheet.getRow(rowNum);
&&& if (null == aRow) {
&&& for (short cellNum = 0; cellNum &= aRow.getLastCellNum(); cellNum++) {
&&&& HSSFCell aCell = aRow.getCell(cellNum);
&&&& if (null == aCell) {
&&&& if (aCell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
&&&&& content.append(aCell.getRichStringCellValue()
&&&&&&& .getString());
&&&& } else if (aCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
&&&&& boolean b = HSSFDateUtil.isCellDateFormatted(aCell);
&&&&& if (b) {
&&&&&& Date date = aCell.getDateCellValue();
&&&&&& SimpleDateFormat df = new SimpleDateFormat(
&&&&&&&& &yyyy-MM-dd&);
&&&&&& content.append(df.format(date));
& response.getWriter().write(content.toString());
BufferedInputStream bis =
& URL url =
& HttpURLConnection httpUrl = // 建立链接
& url = new URL(urlReal);
& httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
& httpUrl.connect();// 获取网络输入流
& bis = new BufferedInputStream(httpUrl.getInputStream());
StringBuffer content = new StringBuffer(&&);
& SlideShow ss = new SlideShow(new HSLFSlideShow(bis));
& Slide[] slides = ss.getSlides();
& for (int i = 0; i & slides. i++) {
&& TextRun[] t = slides[i].getTextRuns();
&& for (int j = 0; j & t. j++) {
&&& content.append(t[j].getText());
&& content.append(slides[i].getTitle());
& response.getWriter().write(content.toString());
BufferedInputStream bis =
& URL url =
& HttpURLConnection httpUrl = // 建立链接
& url = new URL(urlReal);
& httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
& httpUrl.connect();// 获取网络输入流
& bis = new BufferedInputStream(httpUrl.getInputStream());
PDDocument pdfdocument =
& PDFParser parser = new PDFParser(bis);
& parser.parse();
& pdfdocument = parser.getPDDocument();
& ByteArrayOutputStream out = new ByteArrayOutputStream();
& OutputStreamWriter writer = new OutputStreamWriter(out);
& PDFTextStripper stripper = new PDFTextStripper();
& stripper.writeText(pdfdocument.getDocument(), writer);
& writer.close();
& byte[] contents = out.toByteArray();
& String ts = new String(contents);
& response.getWriter().write(ts);
BufferedReader bis =
& URL url =
& HttpURLConnection httpUrl = // 建立链接
& url = new URL(urlReal);
& httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
& httpUrl.connect();// 获取网络输入流
& bis = new BufferedReader( new InputStreamReader(httpUrl.getInputStream()));
StringBuffer buf=new StringBuffer();
& while ((temp = bis.readLine()) != null) {
&& buf.append(temp);
&& response.getWriter().write(temp);
&& if(buf.length()&=1000){
& bis.close();
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1610次
排名:千里之外java在线预览txt、word、ppt、execel,pdf代码 - kanwoerzi - ITeye技术网站
在页面上显示各种文档中的内容。在servlet中的逻辑
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
String bodyText =
WordExtractor ex = new WordExtractor(bis);
bodyText = ex.getText();
response.getWriter().write(bodyText);
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
content = new StringBuffer();
HSSFWorkbook workbook = new HSSFWorkbook(bis);
for (int numSheets = 0; numSheets & workbook.getNumberOfSheets(); numSheets++) {
HSSFSheet aSheet = workbook.getSheetAt(numSheets);// 获得一个sheet
content.append("/n");
if (null == aSheet) {
for (int rowNum = 0; rowNum &= aSheet.getLastRowNum(); rowNum++) {
content.append("/n");
HSSFRow aRow = aSheet.getRow(rowNum);
if (null == aRow) {
for (short cellNum = 0; cellNum &= aRow.getLastCellNum(); cellNum++) {
HSSFCell aCell = aRow.getCell(cellNum);
if (null == aCell) {
if (aCell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
content.append(aCell.getRichStringCellValue()
.getString());
} else if (aCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
boolean b = HSSFDateUtil.isCellDateFormatted(aCell);
Date date = aCell.getDateCellValue();
SimpleDateFormat df = new SimpleDateFormat(
"yyyy-MM-dd");
content.append(df.format(date));
response.getWriter().write(content.toString());
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
StringBuffer content = new StringBuffer("");
SlideShow ss = new SlideShow(new HSLFSlideShow(bis));
Slide[] slides = ss.getSlides();
for (int i = 0; i & slides. i++) {
TextRun[] t = slides[i].getTextRuns();
for (int j = 0; j & t. j++) {
content.append(t[j].getText());
content.append(slides[i].getTitle());
response.getWriter().write(content.toString());
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
PDDocument pdfdocument =
PDFParser parser = new PDFParser(bis);
parser.parse();
pdfdocument = parser.getPDDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
PDFTextStripper stripper = new PDFTextStripper();
stripper.writeText(pdfdocument.getDocument(), writer);
writer.close();
byte[] contents = out.toByteArray();
String ts = new String(contents);
response.getWriter().write(ts);
BufferedReader bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedReader(new InputStreamReader(httpUrl.getInputStream()));
StringBuffer buf=new StringBuffer();
while ((temp = bis.readLine()) != null) {
buf.append(temp);
response.getWriter().write(temp);
if(buf.length()&=1000){
bis.close();
在页面上显示各种文档中的内容。在servlet中的逻辑
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
String bodyText =
WordExtractor ex = new WordExtractor(bis);
bodyText = ex.getText();
response.getWriter().write(bodyText);
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
content = new StringBuffer();
HSSFWorkbook workbook = new HSSFWorkbook(bis);
for (int numSheets = 0; numSheets & workbook.getNumberOfSheets(); numSheets++) {
HSSFSheet aSheet = workbook.getSheetAt(numSheets);// 获得一个sheet
content.append("/n");
if (null == aSheet) {
for (int rowNum = 0; rowNum &= aSheet.getLastRowNum(); rowNum++) {
content.append("/n");
HSSFRow aRow = aSheet.getRow(rowNum);
if (null == aRow) {
for (short cellNum = 0; cellNum &= aRow.getLastCellNum(); cellNum++) {
HSSFCell aCell = aRow.getCell(cellNum);
if (null == aCell) {
if (aCell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
content.append(aCell.getRichStringCellValue()
.getString());
} else if (aCell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
boolean b = HSSFDateUtil.isCellDateFormatted(aCell);
Date date = aCell.getDateCellValue();
SimpleDateFormat df = new SimpleDateFormat(
"yyyy-MM-dd");
content.append(df.format(date));
response.getWriter().write(content.toString());
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
StringBuffer content = new StringBuffer("");
SlideShow ss = new SlideShow(new HSLFSlideShow(bis));
Slide[] slides = ss.getSlides();
for (int i = 0; i & slides. i++) {
TextRun[] t = slides[i].getTextRuns();
for (int j = 0; j & t. j++) {
content.append(t[j].getText());
content.append(slides[i].getTitle());
response.getWriter().write(content.toString());
BufferedInputStream bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
PDDocument pdfdocument =
PDFParser parser = new PDFParser(bis);
parser.parse();
pdfdocument = parser.getPDDocument();
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
PDFTextStripper stripper = new PDFTextStripper();
stripper.writeText(pdfdocument.getDocument(), writer);
writer.close();
byte[] contents = out.toByteArray();
String ts = new String(contents);
response.getWriter().write(ts);
BufferedReader bis =
HttpURLConnection httpUrl = // 建立链接
url = new URL(urlReal);
httpUrl = (HttpURLConnection) url.openConnection();// 连接指定的资源
httpUrl.connect();// 获取网络输入流
bis = new BufferedReader(new InputStreamReader(httpUrl.getInputStream()));
StringBuffer buf=new StringBuffer();
while ((temp = bis.readLine()) != null) {
buf.append(temp);
response.getWriter().write(temp);
if(buf.length()&=1000){
bis.close();
浏览: 694833 次
............................... ...
问一下博主,对Winlicense的授权功能有没有了解,想了解 ...
[url][/url]
这么长啊!可惜基础的不是很会,有没有关于VMProtect加壳 ...}

我要回帖

更多关于 js 图片预览插件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信