| View previous topic :: View next topic |
| Author |
Message |
wippel Newbie

Joined: 21 Feb 2008 Posts: 1
|
Posted: Thu Feb 21, 2008 10:32 am Post subject: Command Line Converting Powertpoint to JPG - Specify Quality |
|
|
I am trying to convert a Powerpoint Document to a JPG using the technique described in http://www.oooforum.org/forum/viewtopic.phtml?t=3772. I have modified the example for PPT and JPG, but, the default quality is not high. How can I do this with higher quality.
My macros looks like this:
Sub ConvertPPTToJPEG( cFile , cFileOut)
cURL = ConvertToURL( cFile )
' Open the document.
' Just blindly assume that the document is of a type that OOo will
' correctly recognize and open -- without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array(_
MakePropertyValue( "Hidden", True ),_
) )
cURL = ConvertToURL( cFileOut )
' Save the document using a filter.
oDoc.storeToURL( cURL, Array(_
MakePropertyValue( "FilterName", "impress_jpg_Export" ),_
)
oDoc.close( True )
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3533 Location: Hamburg, Germany
|
Posted: Thu Feb 21, 2008 1:12 pm Post subject: Re: Command Line Converting Powertpoint to JPG - Specify Qua |
|
|
Try the technique described here http://www.oooforum.org/forum/viewtopic.phtml?t=55177&highlight=impress+export+filterdata
I modified the code a little bit so that you can export all slides at once: | Code: | Sub Main
Dim aFilterData (2) As New com.sun.star.beans.PropertyValue
Dim url As New com.sun.star.util.URL
' Filter dependent filter properties
aFilterData(0).Name = "Quality"
aFilterData(0).Value = 100
aFilterData(1).Name = "PixelWidth"
aFilterData(1).Value = 1600
aFilterData(2).Name = "PixelHeight"
aFilterData(2).Value = 1200
oDocument = thisComponent
oController = oDocument.getCurrentController()
For i = 0 to oDocument.getDrawPages().count-1
slide = oDocument.drawpages(i)
url.complete = "file:///c:/temp/myImpressExport_"+i+".jpg"
Export(slide, url, aFilterData())
Next
End Sub
Sub Export(slide, url, aFilterData)
Dim aExportProperties (2) As New com.sun.star.beans.PropertyValue
aExportProperties(0).Name = "MediaType"
aExportProperties(0).Value = "image/jpeg"
aExportProperties(1).Name = "URL"
aExportProperties(1).Value = url
aExportProperties(2).Name = "FilterData"
aExportProperties(2).Value = aFilterData
Dim uExporter
uExporter = createUnoService("com.sun.star.drawing.GraphicExportFilter")
uExporter.setSourceDocument(slide)
uExporter.filter(aExportProperties())
End Sub |
|
|
| Back to top |
|
 |
Frank.S Newbie

Joined: 02 May 2008 Posts: 3
|
Posted: Fri May 02, 2008 7:40 pm Post subject: methods of thisComponent |
|
|
Hello,
sorry for asking a maybe trivial question:
I've been trying to modify this macro by removing the hard-coded name of the exported file, but short of a list of available methods provided by thisComponent I'm stuck. I've searched api.openoffice.org, but no success.
Can someone provide a push towards the right direction?
Cheers,
Frank. |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3533 Location: Hamburg, Germany
|
Posted: Tue May 06, 2008 11:22 am Post subject: Re: methods of thisComponent |
|
|
| Frank.S wrote: | | I've been trying to modify this macro by removing the hard-coded name of the exported file |
And what did you try to introduce instead of the hard coded name? |
|
| Back to top |
|
 |
Frank.S Newbie

Joined: 02 May 2008 Posts: 3
|
Posted: Fri May 16, 2008 2:00 am Post subject: |
|
|
Hi Hol.sten,
Not too much, as I said, I'm stuck.
Starting from the example you posted on 2008.02.21, I first find out the 'location' of the file that's opened in Impress, then get the name of the slide and finally concatenate both and add suffix '.jpeg'. See code snippet:
| Code: | <snip>
' Get filename of OpenOffice document
Dim location As String
location = oDocument.getLocation()
oController = oDocument.getCurrentController()
For i = 0 to oDocument.getDrawPages().count-1
slide = oDocument.drawpages(i)
slideName = oDocument.drawpages(i).getName()
exportUrl.complete = location+"_"+slideName+".jpg"
Export(slide, exportUrl, aFilterData())
Next
</snip> |
This works ok, but the result is quite clumsy: the exported file has a name like filename.odp_page1.jpg ... I would like to get filename_page1.jpg
So, what I really want, is a method that works like
| Code: | $> basename filename.odp .odp
filename |
I can achieve my goal by clicking my way through File|Export ..., etc.
But I'd like to do this by calling OOffice/Impress/Draw from the command line (in fact, from a script) and invoke a macro, e.g.
| Code: | | $> ooffice -headless macro:///Standard.FranksMacro.Main filename.odp |
Any idea, or suggestion, please? Ta.
Frank. |
|
| Back to top |
|
 |
|
|
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
|