Hello, I am using OOo in headless mode together with PyODConverter (http://www.artofsolving.com/node/26). I made a little change to the script so it will update the Table of Contents before outputting the resulting document: document = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, _unoProps(Hidden=True, ReadOnly=True)
try:
       indexes = document.getDocumentIndexes()
       for i in range(0, indexes.getCount()):
               index = indexes.getByIndex(i)
               index.update()
except:
       pass
document.storeToURL(outputUrl, _unoProps(FilterName=filterName)) However, the indexes aren't updated correctly. I.e. some entries in the ToC point to the wrong page number. It seems OOo needs some time to figure out how many pages are in the document and what title is on what page. I see the same when I open my document in OOo. When I open my document, it starts out saying that there are 10 pages, a second later it's 11 and another second later 12. It seems to be "reflowing" the document several times before everything is layed out correctly (to borrow that term from web browsers). If I delete the layout-cache file from the ODF container (and it's entry in manifest.xml) then it starts out at a pagecount of 18 and reduces back to 12. if I add a 10 second sleep between opening the document and updating the ToC, it does work correctly. But I don't want to add an arbitrary pause in the document conversion. Is there a way to force a reflow through the Python Uno API? Or is there a way to get notified when OOo has finished reflowing and laying out the document, so I can wait for it? Kind regards,
--
Sander Marechal
http://www.jejik.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to