Bom dia a todos!
Estou precisando gerar um arquivo .doc a partir de uma classe modelo que tenho aqui. O programa já gera .PDF mas agora estou precisando gerar o .doc!
Alguém sabe algum material que possa ser útil??
Valeu!!
Bom dia a todos!
Estou precisando gerar um arquivo .doc a partir de uma classe modelo que tenho aqui. O programa já gera .PDF mas agora estou precisando gerar o .doc!
Alguém sabe algum material que possa ser útil??
Valeu!!
O JasperReports + iReports não faz isso?
Tem alguma outra API para isso?
Como o PDF é gerado? Acho que a mesma API (já uqe não é Jasper) deve fazer isso…
.DOC não é um formato publico
uma alternativa é criar seus aquivos em RTF, usando o POI por exemplo.
http://poi.apache.org/
[quote=orlandocn].DOC não é um formato publico
uma alternativa é criar seus aquivos em RTF, usando o POI por exemplo.
http://poi.apache.org/
[/quote]
Correto, eu usei o iText para tal. Só é um tanto programático.
O PDF é gerado assim:
Document documento = new Document(PageSize.LETTER);
documento.addAuthor("AUTOR");
documento.addTitle("Título: "
+ c.coletor.getOutFile());
String file = tmpfile;
File tmp = new File(tmpfile);
tmp.deleteOnExit();
try {
if (out != null) {
file = out;
}
PdfWriter writer = PdfWriter.getInstance(documento,
new FileOutputStream(file));
writer.setPageEvent(new MyPageEvents());
writer.setViewerPreferences(PdfWriter.PageLayoutSinglePage);
writer.setViewerPreferences(PdfWriter.FitWindow
| PdfWriter.DisplayDocTitle);
documento.open();
for (int i = 0; i < charts.length; i++) {
charts[i].makeImage(408, 281/* ,true */);
}
Image imgEx = loadImg(tmppath, CLASSEMODELO1);
Image imgIn = loadImg(tmppath, CLASSEMODELO2);
Image imgAv = loadImg(tmppath, CLASSEMODELO3);
Image imgEi = loadImg(tmppath, CLASSEMODELO4);
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
table.getDefaultCell().setHorizontalAlignment(
PdfPCell.ALIGN_CENTER);
table.getDefaultCell().setVerticalAlignment(
PdfPCell.ALIGN_CENTER);
PdfPCell nullLinha = new PdfPCell(new Paragraph());
nullLinha.setBorder(PdfPCell.NO_BORDER);
float height = documento.getPageSize().height() / 4f, width = documento
.getPageSize().width() / 2;
table.addCell(nullLinha);
if (imgEx != null) {
table.addCell(formatImg(imgEx, width, height));
table.addCell(nullLinha);
}
if (imgIn != null) {
table.addCell(formatImg(imgIn, width, height));
table.addCell(nullLinha);
}
if (imgAv != null) {
table.addCell(formatImg(imgAv, width, height));
table.addCell(nullLinha);
}
if (imgEi != null) {
table.addCell(formatImg(imgEi, width, height));
table.addCell(nullLinha);
}
documento.add(table);
documento.close();
} catch (FileNotFoundException e4) {
e4.printStackTrace();
} catch (DocumentException e1) {
e1.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
Teria como gerar um .DOC com essa mesma API?
Qual é essa API, por acaso é iText (eu vi um PDFWriter no código)?
É o iText mesmo! Versão 2.0.7.
Tem como?
Veja umas respostas acima, um post meu.
fiaux, você tem algum exemplo que possa me ajudar? Agradeceria muito! ;))
Obrigado pela ajuda!
[quote]Creating a basic RTF document:
Creating a basic RTF document works just like creating a basic PDF document:
Document document = new Document();
RtfWriter2.getInstance(document,
new FileOutputStream(“testRTFdocument.rtf”));
document.open();
document.add(new Paragraph(“Hello World!”));
document.close();[/quote]
MUITO OBRIGADO!
Agora é só quebrar a cabeça um pouco aqui!
Obrigado à todos!!!