Bonjour à tous,
je fais des exportations de rapport à l'aide de API Birt, cependant, j'ai les problèms suivants:
- pour le fichier pdf, les images sont tronquées. Comment éviter cela.
- les fichiers excel et powerpoint produits n'ont pas d'images et affichent des caractères inattendus.
Voici le code source utilisé pour générer le format pdf:
Voici le code source utilisé pour générer le format excel:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public void print(){ try { IReportDocument reportDocument = engine.openReportDocument(path); System.out.println("Nombre de page : "+reportDocument.getPageCount()); PDFRenderOption pdfOption = new PDFRenderOption(); pdfOption.setSupportedImageFormats("PNG;GIF;JPG;BMP"); pdfOption.setOutputFormat(IRenderOption.OUTPUT_FORMAT_PDF); pdfOption.setOutputFileName("pdf_output.pdf"); pdfOption.setOption(IPDFRenderOption.DPI,100); pdfOption.setOption(IPDFRenderOption.PAGE_OVERFLOW,IPDFRenderOption.FIT_TO_PAGE_SIZE); IRenderTask renderTask = engine.createRenderTask(reportDocument); renderTask.setRenderOption(pdfOption); //renderTask.setPageRange("4,1-2"); renderTask.render(); renderTask.close(); reportDocument.close(); } catch (EngineException e) { e.printStackTrace(); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public void print(){ try { IReportDocument reportDocument = engine.openReportDocument(path); System.out.println("Nombre de page : "+reportDocument.getPageCount()); EXCELRenderOption xlsOption = new EXCELRenderOption(); xlsOption.setOutputFormat("xls"); xlsOption.setSupportedImageFormats("PNG;GIF;JPG;BMP"); xlsOption.setOutputFileName("excel_output.xls"); IRenderTask renderTask = engine.createRenderTask(reportDocument); renderTask.setRenderOption(xlsOption); renderTask.render(); renderTask.close(); reportDocument.close(); } catch (EngineException e) { e.printStackTrace(); } }
Voici le code source utilisé pour générer le format word:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public void print(){ try { IReportDocument reportDocument = engine.openReportDocument(path); System.out.println("Nombre de page : "+reportDocument.getPageCount()); RenderOption wordOption = new RenderOption(); wordOption.setOutputFormat("doc"); wordOption.setSupportedImageFormats("PNG;GIF;JPG;BMP"); wordOption.setOutputFileName("word_output.doc"); IRenderTask renderTask = engine.createRenderTask(reportDocument); renderTask.setRenderOption(wordOption); renderTask.render(); renderTask.close(); reportDocument.close(); } catch (EngineException e) { e.printStackTrace(); } }
Ci-joint, les fichiers que j'obtiens. Lorsque je génère ces rapports avec le birt viewer, j'ai les même problème.
J'utilise BIRT 2.6.2.
Merci d'avance.
Partager