https://bugzilla.novell.com/show_bug.cgi?id=400493
User eward@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=400493#c3
--- Comment #3 from Eric Ward 2008-06-27 07:50:27 MDT ---
Michael,
Here is one way to generate a pdf from the command line.
- Open writer from the command line:
oowriter
- Select Tools | Macros | Organize Macros | OpenOffice.org Basic ...
- From the OpenOffice.org Basic Macros UI, Under the "Macro from" column on the
left hand side select My Macros | Standard | Module1 and then press the edit
button
- Enter the following basic macros
' Based on code from http://www.oooforum.org/forum/viewtopic.phtml?t=3772
' Save document as an Acrobat PDF file.
Sub SaveAsPDF( cFile )
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 ),))
cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"
cURL = ConvertToURL( cFile )
' Save the document using a filter.
oDoc.storeToURL( cURL, Array(_
MakePropertyValue( "FilterName", "writer_pdf_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
- Now close all of the oowriter windows
- From the command line change into the directory where the file exists that
your interested in converting and run the following commands:
FILENAME=<put the name of the file here>
$(which soffice) "macro:///Standard.Module1.SaveAsPDF($FILENAME)"
Which in my test case the command looked like this
FILENAME=$PWD/Cue\ Cards_Chinese\ Trad_zh_TW.doc
$(which soffice) "macro:///Standard.Module1.SaveAsPDF($FILENAME)"
NOTE= $PWD just returns the full path of the working directory. I believe the
macro needs a complete path to the filename in order to work correctly.
- At this point you should now have an exported pdf in the same directory as
the original file.
If you don't want any GUI to appear at all when running the macro add the
following switch to the command line:
$(which soffice) --invisible "macro:///Standard.Module1.SaveAsPDF($FILENAME)"
Keep in mind that this process will then run in the background. You can check
on the process by doing "ps aux|grep -i soffice". Once the process has
completed, the pdf will be produced.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.