I meger the documents using the below method:
private XComponent agruparDocumentos(List documentos, String
tipoDocumento)
throws Exception
{
final String NOME_ARQUIVO_TEMPORARIO = "arquivo_temp_";
XComponent documentoFinal = getFachadaOpenOffice().criarNovoDocumento();
for (int i = 0; i < documentos.size(); i++)
{
InputStream documentoAAgrupar = (InputStream) documentos.get(i);
ByteArrayOutputStream streamDocumentoAAgrupar = new
ByteArrayOutputStream();
IOUtils.copy(documentoAAgrupar, streamDocumentoAAgrupar);
streamDocumentoAAgrupar.close();
File arquivoTemporario = new File(FachadaOpenOffice.obterInstancia()
.getDiretorioBase()
+ NOME_ARQUIVO_TEMPORARIO + i + "." + tipoDocumento);
FileOutputStream documentoAAgruparTemporario = new FileOutputStream(
arquivoTemporario);
documentoAAgruparTemporario.write(streamDocumentoAAgrupar.toByteArray());
documentoAAgruparTemporario.close();
XTextDocument mxDoc = (XTextDocument) UnoRuntime.queryInterface(
XTextDocument.class, documentoFinal);
XText mxDocText = mxDoc.getText();
XTextCursor mxDocCursor = mxDocText.createTextCursor();
mxDocCursor.gotoEnd(false);
XDocumentInsertable lXDocInsertable = (XDocumentInsertable) UnoRuntime
.queryInterface(XDocumentInsertable.class, mxDocCursor);
PropertyValue[] loadProps = new PropertyValue[0];
String url = getFachadaOpenOffice().criarURL(
arquivoTemporario.getAbsolutePath());
lXDocInsertable.insertDocumentFromURL(url, loadProps);
}
XStorable xstorable = (XStorable) UnoRuntime.queryInterface(
XStorable.class, documentoFinal);
XCloseable xcloseable = (XCloseable) UnoRuntime.queryInterface(
XCloseable.class, xstorable);
if (xcloseable != null)
{
xcloseable.close();
}
return documentoFinal;
}
public XComponent criarNovoDocumento() throws java.lang.Exception
{
String loadUrl = getDiretorioBase() + getTemplateDocumento();
XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime
.queryInterface(XComponentLoader.class, obterComponenteDesktop());
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "private:factory/swriter";
loadProps[1].Value = new Boolean(true);
return xComponentLoader.loadComponentFromURL(criarURL(loadUrl),
"_blank",
0, loadProps);
}
The styles doesn't have the same name as in the template-base doc, I
configure the style in template using OpenOffice GUI "Format -> Style and
Formatting -> Page Style -> First Page" after I set "Format->Paragraph->
Line Spacing" and also "Format -> Alignment"
Cor Nouws wrote:
>
> Hi Aloizio,
>
> aloizio wrote:
>
>> I created one template *.ott which is upload as a writer document. Then I
>> use
>> this template to merge documents.
>> In template I put line spacing equal 1.5cm.
> Do you work with paragraph styles?
> Or with direct formatting?
>
>> When I merge the documents the
> How?
> Paste as unformatted text?
> Or do the styles have the same name as in the template-base doc?
>
>> merged document should have all text with line spacing 1.5, but it
>> doesn't
>> have. could someone help?
>>
>> I set also in template margin left and right to 2cm and 1cm
>> respectivally,
>> this works.
> Yes, that are settings in the page-style.
>
> Regards,
> Cor
>
>
> --
>
> Cor Nouws
> Arnhem - Netherlands
> nl.OpenOffice.org - marketing contact
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Merge-documents-tf2591608.html#a7237710
Sent from the openoffice - api dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]