Hi all, I need your *HELP* The problem is, using "xsl2pdf.py" to convert "tmp.xls" to "tmp.pdf", but the "tmp.pdf" has page info '1' on the head and tmp.xls on the foot, and the excel didnot fill the full pdf page. I want: 1. remove '1' from the head. 2. remove 'tmp.xls' from the foot. 3. extends the excel to fill the full pdf page. How can I achieve these goals by using OpenOffice? Thank you all very much in advance! Wish you all a good day/night. :-)
tmp.xls
Description: MS-Excel spreadsheet
#!/usr/bin/env python # encoding: utf-8
import uno
from os.path import abspath
from com.sun.star.beans import PropertyValue
from com.sun.star.connection import NoConnectException
DEFAULT_OPENOFFICE_PORT = 8100
class ConvertException(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class Excel2PdfConverter():
def __init__(self, port=DEFAULT_OPENOFFICE_PORT):
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
try:
context = resolver.resolve("uno:socket,host=localhost,port=%s;urp;StarOffice.ComponentContext" % port)
except NoConnectException:
raise ConvertException, "failed to connect to OpenOffice.org on port %s" % port
self.desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
def convert(self, inputFile, outputFile, properties={}):
inputUrl = uno.systemPathToFileUrl(abspath(inputFile))
outputUrl = uno.systemPathToFileUrl(abspath(outputFile))
document = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, self._toProperties({"Hidden":True}))
try:
document.refresh()
except AttributeError:
pass
args = self._toProperties({
"FilterName": "writer_pdf_Export",
})
try:
#document.storeToURL(outputUrl, self._toProperties(storeProperties))
document.storeToURL(outputUrl, tuple(args))
finally:
document.close(True)
def _toProperties(self, dict):
props = []
for key in dict:
prop = PropertyValue()
prop.Name = key
prop.Value = dict[key]
props.append(prop)
return tuple(props)
converter = Excel2PdfConverter()
converter.convert("tmp.xls", "tmp.pdf")
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
