pdf
Matthias Prem
How can I store any text document as *.pdf?
/* StoreAnyAsPDF.rex */
/* run from command line */
/* parts of this script are taken from A. Ahammer */
/* connect to server and get the service manager */
xContext = UNO.connect()
XMcf = xContext~getServiceManager
/* get the desktop and XComponentLoader */
xDesktop = UNO.createDesktop(xContext)
xComponentLoader = xDesktop~{%see com.sun.star.frame.XDesktop%XDesktop}~{%see com.sun.star.frame.XComponentLoader%XComponentLoader}
/* loading an existing document */
loadprops = bsf.createArray(.UNO~propertyValue, 1)
loadprops[1] = .UNO~PropertyValue~new
loadprops[1]~Name = "Visible"
loadprops[1]~Value = box("boolean", .true)
xWriterComponent = xComponentLoader~loadComponentFromURL("file:///C:/text.odt", "_blank", 0, loadprops)
/* storing the document as pdf */
xStorable = xWriterComponent~{%see com.sun.star.frame.XStorable%XStorable}
storeprops = bsf.createArray(.UNO~propertyValue, 2)
storeprops[1] = .UNO~PropertyValue~new
storeprops[1]~Name = "FilterName"
storeprops[1]~Value = "writer_pdf_Export"
storeprops[2] = .UNO~PropertyValue~new
storeprops[2]~Name = "CompressMode"
storeprops[2]~Value = 2
xStorable~storeToUrl("file:///C:/text.pdf", storeprops)
/* close the Writer */
xWriterComponent~dispose()
::requires UNO.CLS
Initial version