OO-Snippets: Store actual Document as *.pdf

Commons

Keywordspdf
LanguageooRexx
ApplicationWriter
AuthorsMatthias Prem (initial)
Supported Versions2.0.x  
Supported OSAll  
QuestionHow can I store the actual document as *.pdf?

The document has been saved before under *.odt for example.

Answer

Code-Snippet-Listing (snippet-source)

/* StoreActualAsPDF.rex */
/* Macro */
/* How to store an opened file as *.pdf */

/* get the script context */
xScriptContext=uno.getScriptContext()

/* get the document and the component context */
oDoc=xScriptContext~getDocument
oContext=xScriptContext~getComponentContext

/* defining the storing properties */
xStorable = oDoc~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

/* retrieve url from document */
url=oDoc~getURL()

/* if document has been saved to an url */
if (url<>"") then do
	parse var url url "." .
	url= url || ".pdf"
	xStorable~storeToUrl(url, storeprops)
end

/* if document has not been saved */
else do
	.bsf.dialog~messagebox("File has to be saved first.")
end

::requires UNO.CLS

Changelog

DateUserModification
2006-07-10matthiaspremInitial version

and