I use the following LibreOffice Basic macro code to export a Writer
document to an EPUB file:
exportArgs(0).Name = "URL"
exportArgs(0).Value = exportURL
exportArgs(1).Name = "FilterName"
exportArgs(1).Value = "EPUB"
exportArgs(2).Name = "FilterData"
exportArgs(2).Value = Array( _
Array("RVNGCoverImage",0,imageURL,com.sun.star.beans.PropertyState.DIRECT_VALUE), _
Array("RVNGTitle",0,docTitle,com.sun.star.beans.PropertyState.DIRECT_VALUE), _
Array("RVNGInitialCreator",0,initialCreator,com.sun.star.beans.PropertyState.DIRECT_VALUE), _
Array("RVNGDate",0,Format(Now(), "yyyy-mm-ddThh:mm:ss"),com.sun.star.beans.PropertyState.DIRECT_VALUE))
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(exportDoc.CurrentController.Frame, ".uno:ExportToEPUB", "", 0, exportArgs())
While the above code succesfuly produces a valid EPUB file, the parameters provided for FilterData
– exportArgs(2) – are essentially ignored. When I import the resulting EPUB file into Calibre, the Cover Image, Author (InitialCreator,) and Date are simply not set as specified by the code.
This page indicates that the parameter names I’m using for FilterData
are legit.
If I use .uno:ExportTo
rather than .uno:ExportToEPUB
in the dispatcher command, a dialog is displayed pre-populated with default values: Cover Image URL is blank, Author is populated with the First and Last name as set in LibreOffice’s User Data
Option, and Date is populated with zeros. If I manually enter data for Cover Image, Author, and Date; the Image and Author are recognized when I import the resulting file into Calibre. But Calibre displays the date/time of import regardless of the above code’s reference to Now()
for the RVNGDate
FilterData
parameter.
I have tried using .uno:ExportDirectToEPUB
in place of .uno:ExportToEPUB
without seeing any change in behavior. My question is:
How do I write code that will export a Writer
document to an EPUB document in such a way that I can specify the Cover Image, Author, and Create Date/Time within the macro code rather than requiring me to enter the data manually?
Any suggestions would be appreciated.