Hello Stéphane,
On Friday 16 October 2009, 08:23, Stéphane Bonhomme wrote:
> Hello Ariel,
>
> Thanks for your solution it works fine.
>
> Now I'm trying to set pdf export parameters, but I don't know how to
> access the configuration service using pyuno, may be someone could give
> me the path....
attached is a Python version of
http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export#Accessing_the_configuration
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
# -*- coding: utf-8 -*-
# sample client application
import uno
import unohelper
from com.sun.star.beans import NamedValue
def get_pdf_config_access( xContext ):
"""Access the PDF configuration."""
xConfigurationProvider = xContext.ServiceManager.createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider", xContext )
aNamedValue = NamedValue()
aNamedValue.Name = "nodepath"
aNamedValue.Value = "/org.openoffice.Office.Common/Filter/PDF/Export/"
xConfigurationUpdateAccess = xConfigurationProvider.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess", (aNamedValue,) )
return xConfigurationUpdateAccess
sConnectionStr = "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext"
localContext = uno.getComponentContext()
localServiceManager = localContext.getServiceManager()
xURLResolver = localServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
remoteContext = xURLResolver.resolve( sConnectionStr )
remoteServiceManager = remoteContext.getServiceManager()
xPDFConfig = get_pdf_config_access( remoteContext )
xPDFConfig.setPropertyValue("ReduceImageResolution", True)
xPDFConfig.setPropertyValue("MaxImageResolution", 600)
# When exporting a document to PDF, the default is PDF 1.4
# Since OOo 2.4 the PDF/A-1a is also supported.
# PDF/A-1a is an ISO 19005-1:2005 International Standard.
#
# NOTE that some other options WILL NOT be available if this format
# is selected (UseTaggedPDF, ExportFormFileds, FormsType,
# all security options)
xPDFConfig.setPropertyValue("SelectPdfVersion", 1)
# "Magnification" specifies the action to be performed
# when the PDF document is opened.
# A value of 4 opens with the zoom level specified in the
# "Zoom" property.
xPDFConfig.setPropertyValue("Magnification", 4)
xPDFConfig.setPropertyValue("Zoom", 60)
# When using XMultiPropertySet:setPropertyValues(),
# properties must be alphabetically sorted!
xPDFConfig.setPropertyValues(
( "CenterWindow", "DisplayPDFDocumentTitle", "InitialView", "PageLayout" ),
( True, False, 2, 1 )
)
# commit the changes, otherwise they will be lost!
xPDFConfig.commitChanges()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]