2014年5月17日星期六

Online , Java how to achieve the jsp page online preview document

RT
document upload done
stored in the database is to upload the document path
project needs now is to click on the document name to open the document in a jsp page, kind of like Baidu library preview
document format currently has three kinds of PPT WORD PDF
Internet to find a
Many use poi to resolve the
but currently only done parsing text and parsed out , open it slowly, so certainly not
table format and pictures are resolved not out
very tangled
There are dozens with flexpaper to convert swf file is displayed in the preview
but still could not get some of the software is not free or open source, not just with the commercial version of the software
increasingly tangled

Who do the Demo ah
Online ah
heroes
------ Solution ---------------------------------- ----------
not so simple , it is best to have a background batch upload PDF documents are unified into a format or directly open the front desk to preview the PDF.

conversion process suggested tools , not limited to the Java implementation ; their use be resolved like POI achieve efficiency is too low.
------ Solution ---------------------------------------- ----
have to use third-party plug-ins , otherwise no way do we use third-party companies are plug-ins, such as excel displayed in IE. guess you do not have an example in the search, I have found over and over the
give you an excel example , can only be used in IE , other browsers are not supported.
important is the phrase


IPA: OWCVBA11.CHM yourself to download and play it


<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

    <title>Untitled Page</title>


     <script language="javascript"> 


function document.onkeydown(){
if(event.keyCode == 116){
event.keyCode = 0;
event.returnValue = false;
return;
}
}


if(window.Event){
   document.captureEvents(Event.MOUSEUP);
   } 
 
function nocontextmenu(){
  event.cancelBubble = true
  event.returnValue = false;
  return false;
}
 
function norightclick(e) {
 if (window.Event){
  if (e.which == 2 || e.which == 3)
    return false;
 }else if(event.button == 2 || event.button == 3) {
    event.cancelBubble = true
    event.returnValue = false;
    return false;
 }  
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others


function deleteRecord(){
var Spreadsheet1 = document.all("Spreadsheet1"); 
       //var rowNum = Spreadsheet1.ActiveCell.Row;
//Spreadsheet1.Cells.Rows(rowNum).Delete();
       var rowNums = Spreadsheet1.Selection.Rows;
rowNums.Delete();
}

function undo(){

var Spreadsheet1 = document.all("Spreadsheet1"); 
if(Spreadsheet1.CanUndo){
     Spreadsheet1.Undo();
}else{
     alert("无法执行撤销操作!");
}
}

function clearAll(){
var Spreadsheet1 = document.all("Spreadsheet1"); 
Spreadsheet1.Range("A2:DD500").Cells.Clear();
}

function Spreadsheet1_BeforeContextMenu(x, y, Menu, Cancel){
var cmContextMenu = new Array();
     cmContextMenu[0] = ["撤销操作(&U)", "undo"];
cmContextMenu[1] = null;
cmContextMenu[2] = ["删除行记录(&D)", "deleteRecord"];
cmContextMenu[3] = ["清空所有记录(&A)", "clearAll"];
Menu.Value = cmContextMenu;
//Cancel.Value = true;
}

function Spreadsheet1_CommandExecute(Command, Succeeded){
if(Command == 'undo')  undo();
if(Command == 'deleteRecord')  deleteRecord();
if(Command == 'clearAll')  clearAll();
}

function Spreadsheet1_BeforeKeyDown(KeyCode, Shift, Cancel){
//屏蔽剪切复制
if((Shift == 2) && (KeyCode == 88 || KeyCode == 67)) Cancel.Value = true;
}

function   onload()   { 

var   Spreadsheet1   =   document.all("Spreadsheet1"); 
Spreadsheet1.EnableUndo = false;
//设置显示工具栏
Spreadsheet1.DisplayToolbar = false;

//设置调整大小
Spreadsheet1.ActiveWindow.EnableResize = false;

//alert(arr.length);

//显示"命令和选项"窗口
Spreadsheet1.AllowPropertyToolbox =  false;

//设置单个sheet属性
Spreadsheet1.DisplayWorkbookTabs = true; 

var aa = eval("Spreadsheet1"+"_BeforeContextMenu");
//调用事件
Spreadsheet1.attachEvent("BeforeContextMenu",aa); 
Spreadsheet1.attachEvent("CommandExecute",Spreadsheet1_CommandExecute); 
Spreadsheet1.attachEvent("BeforeKeyDown",Spreadsheet1_BeforeKeyDown); 


      Spreadsheet1.ActiveSheet.Cells.Clear();
      Spreadsheet1.ActiveSheet.Cells(2, 1).Value = "Car";
      Spreadsheet1.ActiveSheet.Cells(3, 1).Value = "Sport-Utility";
      Spreadsheet1.ActiveSheet.Cells(4, 1).Value = "Truck";
      Spreadsheet1.ActiveSheet.Cells(5, 1).Value = "Minivan";


      Spreadsheet1.ActiveSheet.Cells(1, 2).Value = "1998";
      Spreadsheet1.ActiveSheet.Cells(2, 2).Value = 0.2;
      Spreadsheet1.ActiveSheet.Cells(3, 2).Value = 0.06;
      Spreadsheet1.ActiveSheet.Cells(4, 2).Value = 0.17;
      Spreadsheet1.ActiveSheet.Cells(5, 2).Value = 0.13;

      Spreadsheet1.ActiveSheet.Cells(1, 3).Value = "1999";
      Spreadsheet1.ActiveSheet.Cells(2, 3).Value = 0.38;
      Spreadsheet1.ActiveSheet.Cells(3, 3).Value = 0.82;
      Spreadsheet1.ActiveSheet.Cells(4, 3).Value = 0.28;
      Spreadsheet1.ActiveSheet.Cells(5, 3).Value = 0.62;

      Spreadsheet1.ActiveSheet.Cells(1, 4).Value = "2000";
      Spreadsheet1.ActiveSheet.Cells(2, 4).Value = 0.42;
      Spreadsheet1.ActiveSheet.Cells(3, 4).Value = 0.12;
      Spreadsheet1.ActiveSheet.Cells(4, 4).Value = 0.55;
      Spreadsheet1.ActiveSheet.Cells(5, 4).Value = 0.25;

      
    //设置保护区域
    var shtCurrent = Spreadsheet1.ActiveSheet;    

     var rngUsed = shtCurrent.UsedRange;

var rngCurRegion = Spreadsheet1.Range("a2").CurrentRegion;

   alert(rngUsed.Rows.Count);
   //alert(rngUsed.Columns.Count);
//Spreadsheet1.Cells.Rows(2).Delete();

    //shtCurrent.range(shtCurrent.Cells(5, 1),shtCurrent.Cells(5, 4)).Locked = false;
    //shtCurrent.Protection.Enabled = true;

Spreadsheet1.EnableUndo = true;

//alert(Spreadsheet1.XMLData);

    //alert(Spreadsheet1.ActiveWorkbook.XmlMaps(1).MapData);




</script> 

</head>

<body onload="return onload()" >

<form id="form1" runat="server">
<div>  
</div>
</form>

<OBJECT  id="Spreadsheet1" classid="clsid:0002E559-0000-0000-C000-000000000046" name="Spreadsheet1" style="width:100%;height:421px" > 

            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td bgcolor="#336699" height="25" width="10%">&nbsp;</td>
                    <td bgcolor="#666666" width="85%">
                        <font face="宋体" color="white" size="4">
                            <b>&nbsp; 缺少 Microsoft Office Web Components</b>
                        </font>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#cccccc" width="15">&nbsp;</td><td bgcolor="#cccccc" width="500px"><br>
                     <font face="宋体" size="2">此网页要求 Microsoft Office Web Components。
                         <p align="center">
                             <a href="C:/IUware Online/Microsoft Office Professional Enterprise Edition 2003/files/owc11/setup.exe"> 单击此处安装 Microsoft Office Web Components。
                              </a>.
                          </p>
                      </font>
                      <p>
                      <font face="宋体" size="2"> 此网页同时要求 Microsoft Internet Explorer 5.01 或更高版本。</p>
                        <p align="center"/><a href="http://www.microsoft.com/windows/ie/default.htm"> 单击此处安装最新的 Internet Explorer</a>.
                      </font><br>&nbsp;
                    </td>
                  </tr>
              </table>

</OBJECT>
</body>

</html>


------ Solution ------------------------------------- -------
1. use openoffice to pdf convert . swf
2.jsp used flexpaper open . swf file
------ Solution -------------------------- ------------------


correct.
I said before how I deal with :
1. user uploaded word, xls, ppt, pdf after such original documents processed in the background , if not pdf format are converted into pdf format with openoffice
2. obtained in the first step of pdf files can be converted by this tool into the corresponding pdf2swf.exe swf
3. step used in jsp flexpaper generated can preview the swf

OK
------ Solution ----------------------------------- ---------
our items are third-party tools to pay
------ Solution ----------------- ---------------------------
ask your question solved? I have to solve this problem , can help me ?
------ Solution ---------------------------------------- ----
reference openOffice swftools done before
send you a link http://www.cnblogs.com/star-studio/archive/2011/12/09/2281807.html

------ Solution ------------------------------------ --------
should also have some weboffice plug it, the company with the commercial version of the gold grid control , compatible with what are good
------ Solution ------ --------------------------------------
not so troublesome bars , java can be achieved ah. Oh, I've done :

window.onload = function() { 
        
            document.getElementById("divwrapped").innerHTML = "<iframe width='100%' height='100%' src='ajax_pageload.action?path=" + encodeURIComponent(filepath) + "' />";    };


Then in the background : ( write only the key code oh )
response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.wordprocessingml.document");
// 设置下载头信息 
try {
TransmitFile.downLoad(response, strUrl);
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace();
 } 
out.flush();
out.close();



  /**
 * 下载文件
 * @param config
 * @param response
 * @param downLoadFileName
 */
public static void downLoad(HttpServletResponse response,String filePath){
BufferedInputStream bis=null;
BufferedOutputStream  bos=null;
try{
 String filename=filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length());
 response.setContentType("application/x-msdownload");
 response.setHeader("Content-Disposition","filename="+new String(filename.getBytes("gb2312"),"iso8859-1"));
 bis =new BufferedInputStream(new FileInputStream(filePath));
 bos=new BufferedOutputStream(response.getOutputStream()); 
 byte[] buff = new byte[2048];
 int bytesread;
 while(-1 != (bytesread = bis.read(buff, 0, buff.length))) {
  bos.write(buff,0,bytesread);
 }
}catch(Exception e){
     e.printStackTrace();
}finally {
 if (bis != null)
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
 if (bos != null)
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}

      
}

------ Solution ------------------------------------- -------
flexpaper this plugin, I personally think it is very easy to use , have used before .
------ Solution ---------------------------------------- ----
determine if the type of office documents
1. Through openoffice convert files to pdf
2. speaking through swftools convert pdf files into swf format
3. browse through flex web

------ Solution ------------------------------------ --------
top 1L, my suggestion is that if the requirements are not particularly stringent , uniform turn into a pdf document , the front page with adobe reader plug-in to the online preview pdf documents, such as we have just done demand
------ Solution --------------------------------------- -----
nb plugin AC_FL_RunContent
------ For reference only ------------------------ ---------------
may not help you, this thing is done to make money , it is impossible free
------ For reference only - --------------------------------------


Thank you for your help
I imagine the way
------ For reference only ------------------------------ ---------


Demo Or you can give a good example of not before , now on-line project hurry , hurry ah
Thank
------ For reference only --------------------------------- ------
directly open pdf achieved through the online preview, how not ?
------ For reference only -------------------------------------- -
landlord seeking to achieve the right demo grateful ah ah. . . .
------ For reference only -------------------------------------- -
my mailbox 454402218@qq.com
------ For reference only -------------------------- -------------
openoffice and flexpaper to use this combination to achieve . . I study two days before good ! ! Also need to install a few things. . There needs to be sent to you. . .
------ For reference only -------------------------------------- -
above world can only preview the document , if you want to preview documents in other formats , add their own judgment, and then set the header information.


 if(".DOC" .equals(extName)){response.setHeader("Content-type", "application/msword");}
 else if(".DOCX" .equals(extName)){response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.wordprocessingml.document");}
 else if(".PDF" .equals(extName)){response.setHeader("Content-type","application/pdf");}
 else if(".TXT" .equals(extName)){response.setHeader("Content-type","text/html");}
 else if(".XLS" .equals(extName)){response.setHeader("Content-type","application/vnd.ms-excel");}
 else if(".XLSX" .equals(extName)){response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");}
 else if(".PPT" .equals(extName)){response.setHeader("Content-type","application/vnd.ms-powerpoint");}
 else if(".PPTX" .equals(extName)){response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.presentationml.presentation");}
 else if(".BMP" .equals(extName)){response.setHeader("Content-type","image/bmp");}
 else if(".GIF" .equals(extName)){response.setHeader("Content-type","image/gif");}
 else if(".IEF" .equals(extName)){response.setHeader("Content-type","image/ief");}
 else if(".JPEG" .equals(extName)){response.setHeader("Content-type","image/jpeg");}
 else if(".JPG" .equals(extName)){response.setHeader("Content-type","image/jpeg");}
 else if(".PNG" .equals(extName)){response.setHeader("Content-type","image/png");}
 else if(".TIFF" .equals(extName)){response.setHeader("Content-type","image/tiff");}
 else if(".TIF" .equals(extName)){response.setHeader("Content-type","image/tif");

------ For reference only ----------------------------------- ----

look it troublesome to me thank my mailbox 454402218@qq.com
------ For reference only ------- --------------------------------
has been sent to your mailbox. . .
------ For reference only -------------------------------------- -
can send it to my mailbox , I also do this , 365834556@qq.com, grateful
------ For reference only ------------- --------------------------

Before adopting
done this way , but the function is not very powerful.
------ For reference only -------------------------------------- -
landlord , you can send to my mail? I'm looking for this , 1525950302@qq.com grateful
------ For reference only ------------------------ ---------------
landlord, also send me free copies Oh , flexpaper use always reach the desired effect
2633522342@qq.com
------ For reference only ----------------------------- ----------
landlord , you can send to my mail? I'm looking for this , 602749539@qq.com grateful
------ For reference only ---------------------- -----------------
this online viewing . I personally feel that depends on how you are planning : 1 , online documents, so that after the display . 2 , deal with the next line of the document , online direct display .
willing to invest , get hold of the commercial code, and convenient. Refused to vote the money , how simple and how to do .
purely with people views.
------ For reference only -------------------------------------- -
landlord , you can send to my mail? I'm looking for this , 88165868@qq.com grateful
------ For reference only ---------------------- -----------------
read a pdf using iText to read data from the database when generating pdf quickly, and as long as the client installed adobe flash basic can online preview.
If only online preview iText basically no problem .
iText support picture form displayed.
------ For reference only -------------------------------------- -

752915708@qq.com trouble appreciate a copy of it ! ! !
------ For reference only -------------------------------------- -
studied flexpaper, basically based on third-party tools to achieve them will be relatively simple, but do not know if you have not found the file flexpaper only access to the project directory and can not access local files ( such as the file uploaded on the D drive ) to achieve the landlord did not know , or have solved this problem brothers seeking examples ~ 691226682@qq.com
------ For reference only ----- ----------------------------------
are learning , like to refer to demo, I hope my dear friend sent me a grateful brother . 784773798@qq.com
------ For reference only --------------------------------- ------

ie how I can only preview ah , Firefox will not be in , ah, please guide us , thank you
------ For reference only - -------------------------------------
957581081@qq.com trouble to send a recently the company to the task bar , be grateful ! ! !
------ For reference only -------------------------------------- -
wq_1108@qq.com
seeking code ah
------ For reference only ------------------------------- --------
today found a very good document preview online service, you can install your own server , REST interface calls , pure html page, the browser compatibility is very good, in the phone , tablet and computer adaptive perfect preview of different terminals , 1M about the document completely free , recommended for everyone, Website : www.idocv.com
------ For reference only ------------- --------------------------
pro said that you did , give or sub- dome , said the next item? yaodk@neusoft.com
------ For reference only --------------------------------- ------


I need , thank you !
dhdream@126.com

------ For reference only ---------------------------------- -----

  
I need , thank you !   
dhdream@126.com   
 

I also need to thank the 877344151@qq.com
------ For reference only ------------------- --------------------


seeking example , 877344151@qq.com
------ For reference only ------------------------ ---------------
seeking examples , thank you 877344151@qq.com
------ For reference only - -------------------------------------

  
I need , thank you !   
dhdream@126.com   
  with the request, thank you ! ! ! 516412376@qq.com
------ For reference only ------------------------------- --------
seeking to share ! ! !
982910864@qq.com
------ For reference only ----------------------------- ----------
give me a copy of it , 317335525@qq.com. Thank you !
------ For reference only -------------------------------------- -
recent training, teachers arranged the job , the landlord wishers can send a copy to me
Thank you so much . 1206304123@qq.com
------ For reference only --------------------------------- ------
recently encountered this problem , just as needed. Qiufa demo copy. E-mail : 549855879@qq.com
------ For reference only ----------------------------- ----------
landlord, I also want a copy, can also send me a copy , seeking Demo -mail :. lrr1021082712@sina.com
------ For reference only ---------------------------------------
I also want

没有评论:

发表评论