I'm trying to generate a PDF from an odt file using Python and the OpenOffice UNO bridge. It works fine so far, the only problem i'm facing are the export options. By default, OO is using the existing PDF export settings (the one used the last time, or the default if the first time). But I need set these settings manually, for example "UseTaggedPDF" has to be true. This is part of the code where i export the PDF:

try:
    properties=[]
    p       = PropertyValue()
    p.Name  = "FilterName"
    p.Value = "writer_pdf_Export"
    properties.append(p)
    p       = PropertyValue()
    p.Name  = "UseTaggedPDF"
    p.Value = True
    properties.append(p)


    document.storeToURL(outputUrl, tuple(properties))
finally:
    document.close(True)

The PDF is generated but not tagged. What's wrong with this?

有帮助吗?

解决方案

Finaly found the solution on http://www.oooforum.org/forum/viewtopic.phtml?t=70949

try:
    # filter data
    fdata = []
    fdata1 = PropertyValue()
    fdata1.Name = "UseTaggedPDF"
    fdata1.Value = True
    fdata.append(fdata1)

    fdata.append(fdata1)

    args = []
    arg1 = PropertyValue()
    arg1.Name = "FilterName"
    arg1.Value = "writer_pdf_Export"
    arg2 = PropertyValue()
    arg2.Name = "FilterData"
    arg2.Value = uno.Any("[]com.sun.star.beans.PropertyValue", tuple(fdata) )
    args.append(arg1)
    args.append(arg2)

    document.storeToURL(outputUrl, tuple(args))
finally:
    document.close(True)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top