I'm working on putting together the Camp KDE 2009 videos using the excellent
Kdenlive, a non-linear video editor whose name is, well, an acronym for KDE Non LInear Video Editor. More on Kdenlive in a later blog post from me and/or Wade, but trust me -- with the latest versions it's much more stable, and it's getting very good.
Anyways, one of the reasons I'm using it is to splice the slides into the videos, because they're just not readable inside the videos for the most part. So I needed a way to turn each slide into some sort of an image.
It turns out that OO.o doesn't have this capability natively, but some users on the OO.o Forum came up with a script at the bottom of
this page to export each slide into PDF. I modified it to do the following:
- Export to JPG instead of PDF (PNG export didn't work)
- Add extra 0s to numbers such that you always have three digits
The code is pasted below. One really fun (not) thing I found out: VBA (or just OO.o's implementation of it) doesn't really do type checking. As a result, if
r is a string instead of an integer (which I had forgotten), the following code will always execute as True:
If r < 10 ThenAnyways, here is the code, in case it helps anyone at some point:
REM ***** BASIC *****
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "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
Sub SplitPDFs
dim oDoc as object
oDoc = ThisComponent
dim url as string
url = oDoc.getURL()
baseURL = Left( url, Len( url ) - 4 )
nNumPages = oDoc.getDrawPages().getCount()
For nPageToSave = 1 To nNumPages
dim r as string
r = Str(nPageToSave)+"-"+Str(nPageToSave)
If CInt(r) < 10 Then
oDoc.storeToUrl( baseURL+"00"+nPageToSave+".jpg" ), Array( _
MakePropertyValue( "FilterName", "impress_jpg_Export" ), _
MakePropertyValue( "Overwrite", "True"), _
MakePropertyValue( "FilterData", Array( _
MakePropertyValue( "PageRange", r ))))
Else
oDoc.storeToUrl( baseURL+"0"+nPageToSave+".jpg" ), Array( _
MakePropertyValue( "FilterName", "impress_jpg_Export" ), _
MakePropertyValue( "Overwrite", "True"), _
MakePropertyValue( "FilterData", Array( _
MakePropertyValue( "PageRange", r ))))
End If
Next
End Sub