in your case I believe it is logical. Text fields require refreshment in order to have their actual results. I really don't know I have never used next fields but the example in the developers guide refreshes them.
However what I would like to know is what refresh or reformat does at the document level. --- Tim Anderson <[EMAIL PROTECTED]> wrote: > Thanks for the tip. I've inserted the following > between the load and > save - it appears to work: > > XTextFieldsSupplier supplier = > (XTextFieldsSupplier) > UnoRuntime.queryInterface(XTextFieldsSupplier.class, > document); > XEnumerationAccess fields = > supplier.getTextFields(); > XRefreshable refreshable = (XRefreshable) > UnoRuntime.queryInterface(XRefreshable.class, > fields); > refreshable.refresh(); > > Is there an explanation for why this works? > > Thanks, > > Tim > > Kent Gibson wrote: > > also, I believe that user fields themselves > support > > the XRefreshable interface, so you might just try > > refreshing the user fields, instead of the whole > > document. > > > > --- Tim Anderson <[EMAIL PROTECTED]> wrote: > > > > > >> (Originally posted at > >> > >> > > > http://www.oooforum.org/forum/viewtopic.phtml?t=41056) > > > >> I'm using OpenOffice 2.0.3 to convert ODT byte > >> streams to PDF from a > >> servlet. > >> However, the PDF generation doesn't work > correctly > >> unless I introduce a > >> sleep() between the call to > loadComponentFromURL() > >> and storeToURL(). > >> > >> Without the sleep(), a blank page is inserted, > and > >> text from the start > >> of the document is missing. > >> > >> The source document includes user fields, which > >> aren't manipulated > >> during the conversion. > >> The document is ~8K in size, and I'm using a > socket > >> connection. > >> From the forum discussion, the issue seems to be > >> related to the fact > >> that the document has user fields. > >> Can anyone confirm if this is a bug, or suggest a > >> workaround that > >> doesn't involve using sleep()? > >> > >> Thanks, > >> > >> Tim > >> > >> Conversion code is as follows: > >> > >> XComponentLoader loader = // get loader > >> byte[] content = // > get > >> ODT content > >> XInputStream inputStream = new > >> ByteArrayToXInputStreamAdapter(content); > >> PropertyValue[] properties = new > >> PropertyValue[]{ > >> newProperty("ReadOnly", true), > >> newProperty("Hidden", true), > >> newProperty("AsTemplate", true), > >> newProperty("InputStream", > >> inputStream) > >> }; > >> > >> XComponent component = > >> loader.loadComponentFromURL("private:stream", > >> "_blank", 0, properties); > >> > >> Thread.sleep(1000); // required to > produce > >> correct PDF > >> > >> XTextDocument textDocument = > (XTextDocument) > >> UnoRuntime.queryInterface(XTextDocument.class, > >> component); > >> XOutputStreamToByteArrayAdapter > outputStream > >> = new > >> XOutputStreamToByteArrayAdapter(); > >> > >> XStorable storable = (XStorable) > >> UnoRuntime.queryInterface(XStorable.class, > >> textDocument); > >> > >> properties = new PropertyValue[]{ > >> newProperty("OutputStream", > >> outputStream), > >> newProperty("Overwrite", true), > >> newProperty("FilterName", > >> "writer_pdf_Export") > >> }; > >> > >> storable.storeToURL("private:stream", > >> properties); > >> outputStream.closeOutput(); > >> > >> byte[] pdfContent = > >> outputStream.getBuffer(); > >> > >> > >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
