pro wrote:I work on oosdk and try to load whole content of html into doc.when i tried to load dynamic (ie
http://www.google.com etc) html content into doc its not loaded some ioerrorcode exeption occured.As per oo forum concern com.sun.star.text.WebDocument not provide any web/writer doc api name so its gives this exception. So sir how can i get this type of content into doc?please send me the code or ur guidence to solve it.
I read through some of the older posts in OOo forums concerning loading HTML and gave finally the following Java code a try (using Ubuntu 10.04, OOo 3.2.0, NetBeans 6.8, Java 1.6.0.16,
bootstrapconnector.jar):
Code: Select all
import com.sun.star.comp.helper.BootstrapException;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import ooo.connector.BootstrapSocketConnector;
public class LoadHtmlFromUrl {
public static void main(String[] args) throws BootstrapException, Exception {
String oooExeFolder = "/usr/lib/openoffice/program/";
XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
XMultiComponentFactory xMultiComponentFactory = xContext.getServiceManager();
XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext));
String loadURL;
loadURL = "http://www.google.com";
//loadURL = "file:///tmp/html/google/google.html"; // Created with "Save As ..." in Google Chrome
//loadURL = "http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/overview.html";
//loadURL = "http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html";
//loadURL = "http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html";
Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, null);
}
}
The code produced no ioerrorcode exeption. I made several runs, one for each given loadURL example. After each run and always after some time OOo came up with a window showing at least some content.
Due to the fact that the Google page uses heavily JavaScript and CSS you get nearly nothing loaded in OOo. The result is far away from what you see in a web browser.
As an other example I tried several pages from the Spring documentation. The text of the pages is shown ok in OOo. But loading them directly from the web gives another problem, if you try to automate it: OOo does not load the pictures together with the HTML code. The pictures only get loaded after you scroll down in OOo to the pictures.
In my opinion OOo is totally useless for getting web pages dynamically from the web.
pro wrote:so i save dynamic page in m/c and then tried to load the same into doc,its loaded but not look same as the front-end view of html page in browser.Mainly its not mention style, not wellorder,not getting img etc.
All mentioned differences are caused by OOo's inability to process CSS and JavaScript in an HTML-document.
pro wrote:How can i get content in doc same as front-end view of html n browser?
At least not with OOo. And due to OOo's CSS limitations OOo will never be useful for this.
pro wrote:any other tools/open source through which i can do that using java technology.
No idea.