OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to convert HTML into OpenOffice File?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
wangxianlg
Power User
Power User


Joined: 10 Aug 2004
Posts: 67

PostPosted: Wed Aug 11, 2004 12:38 pm    Post subject: How to convert HTML into OpenOffice File? Reply with quote

Hi All,

How can I convert HTML file into OpenOffice text document by programming? In another words, is there any component in OpenOffice I can use to convert HTML file into OO text documents?

Please help...

Thanks

Alan
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Aug 11, 2004 12:54 pm    Post subject: Reply with quote

See this....
http://www.oooforum.org/forum/viewtopic.php?p=44631#44631

In particular see these....

Open HTML with Writer not Web in order to export
http://www.oooforum.org/forum/viewtopic.php?t=3973
http://www.oooforum.org/forum/viewtopic.php?p=44367#44367
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
wangxianlg
Power User
Power User


Joined: 10 Aug 2004
Posts: 67

PostPosted: Thu Aug 12, 2004 5:38 am    Post subject: Reply with quote

Thanks for your replay.

I am running my web application on windows server uisng IIS 5.0. Is that possbile for me to write a batch file and run on windows enviroment to convert HTML into OO text document.

I am new to the OO software. Please give me an example if it's possible.

Thanks again

Razz

Alan
Back to top
View user's profile Send private message
wangxianlg
Power User
Power User


Joined: 10 Aug 2004
Posts: 67

PostPosted: Thu Aug 12, 2004 6:16 am    Post subject: Reply with quote

Hi DannyB.

I looked at your post on Mon Feb 16, 2004 7:53 am.

Private Sub Form_Load()
' Get the service manager, as a COM object.
' Everything else about OOo comes directly or indirectly from
' the Service Manager object.
Set oServiceManager = CreateObject("com.sun.star.ServiceManager")

' Get the Desktop object.
Set oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop")

'-----
' A document conversion consists of three steps.
' 1. Open a document.
' If the document is of a format that OOo automatically knows how to open
' then it is not necessary to use a filter.
' If OOo automatically uses a filter you don't want, or if OOo doesn't
' automatically know what filter to use, then you must specify
' which improt filter to use.
' 2. Save document.
' If you want to save the document in OOo's own native document format
' then no export filter is necessary.
' If you want to save in some foriegn document format, then you
' must specify an export filter.
' 3. Close the document.
'-----

'========== Open Document ==========

' Open a document. Use no import filter.
' OOo must be able to automatically recognize what import filter to used).
Dim aNoArgs()
' Open an OOo native doucment test.sxw.
Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.sxw", "_blank", 0, aNoArgs())
' Open a MS Word document, test.doc.
' Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.doc", "_blank", 0, aNoArgs())

' Alternative...
' Open a document using an import filter.
' Dim aOpenArgs(0) As Object

' Open an HTML document into Writer.
' (If we had not used this import filter, then OOo would automatically
' open HTML into Web, not Writer.)
' Set aOpenArgs(0) = MakePropertyValue("FilterName", "HTML (StarWriter)")
' Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.html", "_blank", 0, aOpenArgs())

' Open an RTF document into Writer.
' Set aOpenArgs(0) = MakePropertyValue("FilterName", "Rich Text Format")
' Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.rtf", "_blank", 0, aOpenArgs())


'========== Save Document ==========

' Save document in native form. Use no export filter.
' Dim aNoArgs()
' Call oDoc.storeToURL("file:///C:/Test.sxw", aNoArgs())

' Alternative...
' Save document using an export filter.
Dim aSaveArgs(0) As Object

' Save document in MS Word format.
Set aSaveArgs(0) = MakePropertyValue("FilterName", "MS Word 97")
Call oDoc.storeToURL("file:///C:/Test.doc", aSaveArgs())

' Save document in Rich Text Format.
Set aSaveArgs(0) = MakePropertyValue("FilterName", "Rich Text Format")
Call oDoc.storeToURL("file:///C:/Test.rtf", aSaveArgs())

' Save document in PDF.
Set aSaveArgs(0) = MakePropertyValue("FilterName", "writer_pdf_Export")
Call oDoc.storeToURL("file:///C:/Test.pdf", aSaveArgs())

' Save document in HTML.
Set aSaveArgs(0) = MakePropertyValue("FilterName", "HTML (StarWriter)")
Call oDoc.storeToURL("file:///C:/Test.html", aSaveArgs())


'========== Close Document ==========

Call oDoc.Close(True)
End Sub


I am just wondering if you could let me know which component I have to reference in order to use this program. Right now I am using Microsoft ASP.NET to design the application.

Please bare with me I am really new to the OO software

Thaks

Alan
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Thu Aug 12, 2004 7:24 am    Post subject: Reply with quote

wangxianlg wrote:
I am just wondering if you could let me know which component I have to reference in order to use this program. Right now I am using Microsoft ASP.NET to design the application.


Not really sure what you're asking? Do you mean COM component? OOo component?

I don't know much at all about Microsoft technologies. I make an effort to avoid them to the maximum extent possible. So it is difficult for me to answer. OOo is available presently, as a COM object. In various languages (i.e. Visual Basic, Visual FoxPro, Borland Delphi, etc.) you must create a com object to get the Service Manager. (In VB and VFP you use CreateObject() to do this, as in the example you quoted above.) Once you have the Service Manager as a COM object, you call methods on it, such as createInstance() to to create other UNO services, such as the Desktop. From the Desktop object, you call methods, such as loadComponentFromURL () to open a document.

Maybe your question is really: How do I create a COM object from .NET?
Answer: I have no idea.

There is an effort to create a .NET/Mono to UNO bridge. In the future it will be possible to directly manipulate OOo from .NET languages without going through COM.

wangxianlg wrote:
I am running my web application on windows server uisng IIS 5.0. Is that possbile for me to write a batch file and run on windows enviroment to convert HTML into OO text document.


If you're on IIS, then maybe you are also using ASP? VBScript? If OOo is installed in the same computer, then maybe you can just write the VB code directly into ASP to access OOo and forget about the command line?

Yes, I think it would be possible to write a batch file, called by your web page, such that the batch file issues the fully pathname qualified command line to run OOo with a macro url. Inside OOo, a global macro is called which does the conversion. That approach should work. It might even be thread safe?
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
wangxianlg
Power User
Power User


Joined: 10 Aug 2004
Posts: 67

PostPosted: Thu Aug 12, 2004 7:50 am    Post subject: Reply with quote

Sorry, I didn't make myself clear.

I tried to modified code I quoted above and there are something I am not quite understand.

' Alternative...
' Open a document using an import filter.
' Dim aOpenArgs(0) As Object

' Open an HTML document into Writer.
' (If we had not used this import filter, then OOo would automatically
' open HTML into Web, not Writer.)
' Set aOpenArgs(0) = MakePropertyValue("FilterName", "HTML (StarWriter)")
' Set oDoc = oDesktop.loadComponentFromURL("file:///C:/Test.html", "_blank", 0, aOpenArgs())


What does Set aOpenArgs(0) = MakePropertyValue("FilterName", "HTML (StarWriter)")
mean?

MakePropertyValue belongs to which object. When I tried to compile it, VB gives me error message.

Please help me out

Thanks

Alan
Back to top
View user's profile Send private message
Didier ALAIN
General User
General User


Joined: 14 Aug 2004
Posts: 17
Location: Paris, France

PostPosted: Sat Aug 14, 2004 1:04 pm    Post subject: Reply with quote

MakePropertyValue is a function written (thanks to DanyB !) to convert UNO structures in VB arrays, see http://api.openoffice.org/docs/DevelopersGuide/ProfUNO/ProfUNO.htm#1+4+4+5+3+Usage+of+Types

Here is the function (or perhaps a variant, not sure) :
Code:

Function MakePropertyValue(cName, uValue) As Object
   
    Dim oPropertyValue As Object
   
    Set oPropertyValue = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
    oPropertyValue.Name = cName
    oPropertyValue.Value = uValue
   
    Set setOOoProp = oPropertyValue

End Function
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Aug 16, 2004 10:42 am    Post subject: Reply with quote

For the definition of MakePropertyValue, and much more, see these articles....


Open and Create documents, various prog. languages
http://www.oooforum.org/forum/viewtopic.php?t=5252


MakePropertyValue function
http://www.oooforum.org/forum/viewtopic.php?t=5108
In Visual Basic...
http://www.oooforum.org/forum/viewtopic.php?p=22029#22029
In Python...
http://www.oooforum.org/forum/viewtopic.php?p=26198#26198
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group