DOC to PDF Re: IBM Joins OpenOffice.org Community With Full Force!

"valery_vi" <[email protected]> Tue, 11 Sep 2007 10:56:57 -0000
Newsgroups gmane.comp.windows.autoit.user
Message-ID <[email protected]>
To be more clear I add this script 'ToPDF' (written by me, 11 October
2005). It shows how one can convert MS Office DOC (and text) file into
PDF.

Global $SM, $Desktop, $Document, $Url
$SM 		= ObjCreate("com.sun.star.ServiceManager")
$Desktop	= $SM.createInstance("com.sun.star.frame.Desktop")

$FileName = FileOpenDialog( "Choose a file.", @ScriptDir, "MS Office
Files (*.doc;*.txt)", 1 )
if @Error then
	MsgBox(0, $ScriptTitle, "MS Office Document skipped")
	exit
endif
if StringRight($FileName, 3) = "doc" then
	$Ext = ".doc"
else
	$Ext = StringRight($FileName, 4)
endif

$Url = "file:///" & StringReplace($FileName, "\", "/")
MsgBox(0, "PDFConverter", "OpenFile Url is " & $Url )
OpenFile($Url)

$Url = StringReplace($Url,$Ext,".pdf")
MsgBox(0, "PDFConverter", "SaveFile Url is " & $Url )

SaveFile($Url)
exit

;================================
; Open Document
func OpenFile($Url)
dim $D, $p
	$D = ObjCreate("Scripting.Dictionary")
	$p = $SM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
	$p.Name = "Hidden"
	$p.Value = True
	$D.Add(0,$p)
	$Document = $Desktop.LoadComponentFromURL($URL,"_blank",0,$D.Items)
endfunc

;================================
; Save Document as PDF file
func SaveFile($Url)
dim $R, $fp0, $fp1, $fp2, $fp3 
	$R = ObjCreate("Scripting.Dictionary")

	;Set filter name
	$p0 = $SM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
	$p0.Name = "FilterName"
	$p0.Value = "writer_pdf_Export"
	$R.Add(0,$p0)

	;Set compession mode
	$p1 = $SM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
	$p1.Name = "CompressionMode"
	$p1.Value = "1"
	$R.Add(1,$p1)

	;Set count of pages
	$p2 = $SM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
	$p2.Name = "Pages"
	$p2.Value = "All"
	$R.Add(2,$p2)

	;Set overwrite mode
	$p3 = $SM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
	$p3.Name = "Overwrite"
	$p3.Value = "1"
	$R.Add(3,$p3)

	$Document.StoreToURL($Url,$R.Items)
endfunc

Now AutoIt's script of this kinds will be more actual, I think.

Enjoy,
Valery

--- In [email protected], "valery_vi" <shehrer1@...> wrote:
>
> > 	Why is this being posted to this list?  Please correct me if I
> > 	am wrong, but isn't this list supposed to be about AutoIT?
> 
> Yes. That's right. 
> 
> > 	What does IBM & OpenOffice have to do with AutoIT?  
> 
> This group has members which early automated OpenOffice tools, though.
> 
> > 	What does the Russian language translation (and back to
> > 	English) have to to with AutoIT?
> 
> 2. There is ATranslation script in Files/Misc of this group. So I
> tried to use this Windows Live Translator to automate their online
> service. My first result of service testing is here.
> 
> > 	Can we please stay on-topic?
> 
> I'm doing all to be in thread. It seems to be almost in IT which you
> can automate. Isn't it?
> 
> :-)
> 
> Valery
> 
> --- In [email protected], "John R. Dennison" <jrd@> wrote:
> >
> > On Tue, Sep 11, 2007 at 06:24:22AM -0000, valery_vi wrote:
> > > BTW. MS created Windows Live Translator:
> > 
> > 	The rest of this totally off-topic message removed.
> > 
> > 	Why is this being posted to this list?  Please correct me if I
> > 	am wrong, but isn't this list supposed to be about AutoIT?
> > 
> > 	What does IBM & OpenOffice have to do with AutoIT?  
> > 
> > 	What does the Russian language translation (and back to
> > 	English) have to to with AutoIT?
> > 
> > 	Can we please stay on-topic?
> > 
> > 
> > 
> > 							John
> > 
> > -- 
> > "I'm sorry but our engineers do not have phones."
> > As stated by a Network Solutions Customer Service representative
> when asked to
> > be put through to an engineer.
> > 
> > "My other computer is your windows box."
> >                                      Ralf Hildebrandt
> > <sxem> trying to play sturgeon while it's under attack is apparently
> not fun.
> > 
> > 
> > [Non-text portions of this message have been removed]
> >
>