Open MS Word or Excel Stream in JSP Program

In order to avoid the temporary file in the server, edraw office  viewer component provided a httpopenfilefromstream method to open the office document from file stream directly. It works in the JSP environment.

For example:

Getfile.jsp example code:

String downloadDirName = request.getSession().getServletContext().getRealPath(DOWNLOAD_RELATIVE_PATH);
 String downloadFileName = downloadDirName + “/” + fileMap.get(PARAM_DOCUMENT_ID).getString();
 File downloadFile = new File(downloadFileName);
 if (downloadFile.exists()) {
  byte[] buffer = new byte[4096];
  BufferedOutputStream output = null;
  BufferedInputStream input = null;
  try {
   output = new BufferedOutputStream(response.getOutputStream());
   input = new BufferedInputStream(new FileInputStream(downloadFileName));
   output.write(“EDA_STREAMBOUNDARY”.getBytes());
   int n = -1;
   while ((n = input.read(buffer, 0, buffer.length)) > -1) {
    output.write(buffer, 0, n);
   }
   output.write(“EDA_STREAMBOUNDARY”.getBytes());
   output.flush();
  } catch(Exception e) {
   e.printStackTrace();
  } finally {
   if (output != null) output.close();
   if (input != null) input.close();
  }
 }
 else {
  System.out.println(“[OfficeViewer Error] 404 File not found!”);
  System.out.println(fileItemList.toString());
 }

Open example code:

$(“OA1″).HttpInit();
$(“OA1″).HttpAddpostString(“DocumentID”, “sample.doc”);
$(“OA1″).HttpOpenFileFromStream(“http://192.168.1.1:8020/path/getfile.jsp“);

Is there a way to run ActiveX components in Firefox?

Is there a way to run ActiveX components in Firefox through the use of a plugin?

I seem to have found a solution:

http://code.google.com/p/ff-activex-host/

“This Firefox plugin makes it possible to use ActiveX controls in Firefox. It is based on the Gecko NPAPI and provides full access to the hosted control (events, functions, properties).”

Other ActiveX plug-in that works. It is called neptune. See for more info http://www.meadroid.com/neptune/index.htm

Microsoft Word web toolbar enable

Hi, 

We develop a web document app using DSOFRAMER.

We have a lot of issues… one of them is that in Office 2003 when our application open a word document it enable the word toolbar.

 

With your product, is posible to hide it programmatically ? 

If the customer uses Office 2007, the web office documents can open good in the web browser or directly open the Word´s program ?

 

Thanks in advance

 

 

With your product is posible to hide this toolbar programmaticaly ?

Other question, if the customer uses Office 2007, the word document opens in the web page or open Word´s program ?

Thanks in advance,

Emilio

 

Inserts a break to opened Word file programmatically

boolean InsertBreak([in] WdBreakType BreakType);
Inserts a break to opened Word file.
BreakType: The break type. WdBreakType.
typedef enum WdBreakType
{
wdPageBreak = 7,
wdColumnBreak = 8,
wdSectionBreakNextPage = 2,
wdSectionBreakContinuous = 3,
wdSectionBreakEvenPage = 4,
wdSectionBreakOddPage = 5,
wdLineBreak = 6,
wdLineBreakClearLeft = 9,
wdLineBreakClearRight = 10,
wdTextWrappingBreak = 11,
}WdBreakType;
Example
The following java script shows how to insert a line break.
function InsertBreak_Example ()
{
Edword.InsertBreak( 6 );
}

How to disable the file command buttons

The Office Viewer Component provides the method “EnableFileCommand” to allow the developers to disable the File command in the MS office program.

If you are developing a web application, you can set the initial functions in the “NotifyCtrlReady” event.

function OA1_NotifyCtrlReady() {
document.OA1.EnableFileCommand(0) = false; //FileNew = 0
}
<SCRIPT LANGUAGE=javascript FOR=OA1 EVENT=NotifyCtrlReady>
<!–
OA1_NotifyCtrlReady();
//–>
</SCRIPT>

More File Command ENUMS:

typedef enum FileCommandType
{
FileNew = 0,
FileOpen,
FileClose,
FileSave,
FileSaveAs,
FilePrint,
FilePageSetup,
FileProperties,
FilePrintPreview
} FileCommandType;

How to upgrade the activex control in your program

After uninstall the old version and install the upgrade version, follow steps.

For HTML, PHP, ASp, JSP, ASP.NET application, you need change the version number in the Object tag.

<object classid=”clsid:6BA21C22-53A5-463F-BBE8-5CF7FFA0132B” id=”OA1″ width=”674″ height=”500″ codebase=”http://www.ocxt.com/download/officeviewer.cab#6,0,612,1“>

For VC project, you need go to the form and delete the component. Then delete the OfficeViewer1.h and OfficeViewer1.cpp file from your project. Save project then add the Edraw Office Viewer Component from the Toolbox. Then create a blank VC project based on Dialog. Add Edraw office Viewe Component to the Toolbox. Drag it to the dialog. Add variable for the component. You can find the OfficeViewer1.h and OfficeViewer1.cpp file in the new project. Copy the two files to your exsit project. Add exsit items…

For VB project, you need modify these files.

In OfficeViewer.frm

Object = “{F6F03022-1646-4426-A912-1F26464E81AB}#6.0#0″; “officeviewer.ocx”

In OfficeViewer.vbp

Object={F6F03022-1646-4426-A912-1F26464E81AB}#6.0#0; officeviewer.ocx

For C# or VB.NET project, you need delete the component from your form. Then delete the AxOfficeViewer and OfficeViewer references. Then right click the Toolbox and choose item… In the popup Choose Toolbox Items dialog click the COM Component. Then click the Browse… In the Edraw Office Viewer  component install folder, choose the officeviewer.ocx. Then click OK. Drag the component to your form.

ActiveX controls running in the IE process cannot install updates themselves

When IE is in Protected Mode on Windows Vista, ActiveX controls running in the IE process cannot install updates themselves. This is because IE and ActiveX controls do not have write access to most locations in the file system or registry under Protected Mode. As a result, it’s best to use a separate executable to download and install the update. You can further protect users against “man-in-the-middle” attacks by using an SSL connection to download updates. For more information on Protected Mode see the technical article Understanding and Working in Protected Mode.

Similar to the initial install process, your executable will need administrative privileges to install updates for all users on the machine.  To request administrative privileges on Windows Vista, create an application manifest for your executable with the following requested execution level:

<requestedExecutionLevel
level=”requireAdministrator”/>

Note that Windows Vista will see the requested execution level and display a User Account Control (UAC) dialog so the user can elevate the update executable out of Protected Mode.

Pass optional parameters when you call a function in Visual C++

When you call a method that has optional parameters from Visual C++, you cannot omit the optional parameters. You need to pass a special VARIANT instead.

Some methods have “optional” parameters. In Visual Basic, you can omit them when calling the method. However, when calling with Visual C++, you have to pass a special VARIANT whose .vt field has the value VT_ERROR and .scode field has the value DISP_E_PARAMNOTFOUND. That is:

VARIANT varOpt;
varOpt.vt = VT_ERROR;
varOpt.scode = DISP_E_PARAMNOTFOUND;
OfficeViewer1.OfficeProtectDocument(varOpt);

Print MS Word Document to the special printer

When you use the PrintOut method to print the word document with the  component, you maybe get the follow error.

This error can appear if a default printer has not been designated or if the application is unable to locate an existing default printer. To correct this problem, try one of the following in Microsoft Windows:
If a printer is not available in the Print dialog box, add a printer.
If the application cannot find an existing printer that is already installed, set the printer as the default printer.
If a default printer is installed but the application is unable to use it, uninstall the printer driver, and then install the latest version of the printer driver.
If the printer is on a print server, make sure the printer is available, the network is functioning, the server is not stalled, the printer is not out of paper, or the printer is not suspended by the administrator. Printing issues associated with a network printer are best handled by your local network administrator.
For more information about setting up and troubleshooting printer connections, see Windows Help and Support. (Click the Start button, and then click Help and Support.)

Word cannot print. There is no printer installed.

There are some solutions for it.

1. Call the ShowDialog 4 to use the default printer.

2. Word:
    CWordApplication app(m_wnd.get_Application()); 
    CString strOldPrinter = app.get_ActivePrinter();
    app.put_ActivePrinter(strPrinter); 
    app.PrintOut(varFalse, varOptional, varOptional, varOptional,
        varOptional, varOptional, varOptional, varOptional, varOptional,
        varOptional, varOptional, varOptional, varOptional, varOptional,
        varOptional, varOptional, varOptional, varOptional, varOptional); 
    app.put_ActivePrinter(strOldPrinter);

Hide the Office ActiveX Control in Runtime

If you would like to hide the EDraw Office Viewer ActiveX Control in runtime, you need call the “OfficeObjectVisable” method.

For example: axOfficeViewer1.OfficeObjectVisable = false;

The follow code will lead to an error in C#.

axOfficeViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
axOfficeViewer2.Visible = false;
axOfficeViewer3.Visible = false;