Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: pyuno and PDF output

Reply
Thread Tools

Re: pyuno and PDF output

 
 
w chun
Guest
Posts: n/a
 
      06-24-2006
> Subject: pyuno and PDF output
> From: "Sells, Fred" <fred at adventistcare.org>
> Date: Thu May 4 19:20:57 CEST 2006
>
> I can use java to output a PDF file using uno, but when I try to do it in
> python, I get an IO Exception with no added information. The relevant code
> snippet follows:
>
> from com.sun.star.beans import PropertyValue
> PDF = PropertyValue( "FilterName" , 0 , "writer_pdf_Export", 0 )
> doc2.storeAsURL("file:///C:/alleclipse/OpenOffice/test2.pdf", (PDF,) )
>
> if I don't specify any properties, it writes an "odt" file just fine, but
> when I specify (PDF,) it breaks.
>
> Traceback (most recent call last):
> File "oomerge.py", line 137, in ?
> test1()
> File "oomerge.py", line 74, in test1
> doc2.storeAsURL("file:///C:/alleclipse/OpenOffice/test2.pdf", (PDF,) )
> __main__.com.sun.star.task.ErrorCodeIOException



fred,

(man, i hate seeing that error too... it gets old *fast*.)
a couple of suggestions here:

1. use unohelper with filenames (see #3 below)
import unohelper

2. use the short form to instantiate a PropertyValue

REPLACE:
PDF = PropertyValue("FilterName", 0, "writer_pdf_Export", 0)

WITH:
PDF = PropertyValue("FilterName", "writer_pdf_Export")

3. use storeToURL() as opposed to storeAsURL()

REPLACE:
doc2.storeAsURL("file:///C:/alleclipse/OpenOffice/test2.pdf", (PDF,))

WITH:
doc2.storeToURL(unohelper.absolutize(
unohelper.systemPathToFileUrl('C:/alleclipse/OpenOffice/test2.pdf'),
unohelper.systemPathToFileUrl('test2.pdf')), (PDF,))

let us know how/if/whether this works.

HTH,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pyuno and calc luca72 Python 0 11-06-2007 04:03 PM
Re: pyuno and PDF output w chun Python 0 07-01-2006 03:44 AM
pyuno and PDF output Sells, Fred Python 0 05-04-2006 05:20 PM
pyuno and oootools with OpenOffice 2.0 Sells, Fred Python 0 05-04-2006 03:37 PM
PyUNO: Python bridge distributed with new OpenOffice.org Jochen Knuth Python 0 07-15-2003 09:59 AM



Advertisments