Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > Jasper
Jasper Forum d'entraide sur Jasper Reports. Avant de poster --> FAQ Jasper, Tutoriels Jasper
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 31/07/2007, 13h49   #1
Membre Expert
 
Avatar de lazarel
 
Homme
Consultant informatique
Inscription : mai 2007
Messages : 893
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 30
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultant informatique
Secteur : Aéronautique - Marine - Espace - Armement

Informations forums :
Inscription : mai 2007
Messages : 893
Points : 1 360
Points : 1 360
Par défaut [Servlet]Problème JRHtmlExporter images non visibles ?

Bonjour,


J'ai un problème au niveau des images lors de la génération de rapport en HTML dans une application WEB (Tomcat 5.5).En fait je n'arrive pas à afficher les images de mon rapport (logos) pour la génération de rapport en format HTML.

Dans mon rapport celle-ci est définie par :
Code :
new java.io.File($P{BaseDir},"logo.jpg")
BaseDir étant de type String est correspondant au chemin suivant /report/jasper/image dans mon application WEB.

Dans ma servlet j'utilise ceci :
Code :
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
28
29
30
31
32
 
response.setContentType("text/html");
response.setHeader("Content-disposition", "filename="+realName+".html");
 
JRHtmlExporter exporter = new JRHtmlExporter();
 
exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, servletOutputStream);
 
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_WRITER,out);
HashMap<Object, Object> fontMap = new HashMap<Object, Object>();
 
Map<String, Object> imagesMap = new HashMap<String, Object>();
imagesMap.put("logo.jpg", getServletContext().getRealPath("/report/jasper/image/logo.jpg"));
 
request.getSession().setAttribute("IMAGES_MAP",imagesMap);             
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,imagesMap);
 
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"/report/jasper/image?image=");
exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,getServletContext().getRealPath("/report/jasper/image"));
 
exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,Boolean.TRUE);
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, "px");
exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.FONT_MAP, fontMap);
 
exporter.exportReport();
 
servletOutputStream.flush();
servletOutputStream.close();
Mon image se situe donc dans /report/jasper/image et se nomme logo.jpg.

Le problème c'est que lors de la génération du code HTML j'ai :
Code :
<img src="/report/jasper/image?image=img_0_0_0" border="0" style="width: 70px" alt=""/>
Donc le problème vient forcément de la mais je ne sais pas comment faire pour y remédier.

J'accepte toutes les bonnes volontés
lazarel est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/10/2007, 13h24   #2
Invité de passage
 
Inscription : octobre 2007
Messages : 1
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 1
Points : 1
Points : 1
Par défaut c'est dans la synthaxe de l'URI

Citation:
Envoyé par lazarel Voir le message
Bonjour,

Comme tu l'as déjà remarqué, je pense que ton problème c'est dans la synthaxe de l'URI, en fait, tu dois préciser le nom de ton fichier image "logo.jpg" avant le "?" càd tu dois préciser pour IMAGES_URI la chaîne suivante:
"/report/jasper/image/logo.jpg?image=" et normalement, ça doit marcher.

Bonne chance



J'ai un problème au niveau des images lors de la génération de rapport en HTML dans une application WEB (Tomcat 5.5).En fait je n'arrive pas à afficher les images de mon rapport (logos) pour la génération de rapport en format HTML.

Dans mon rapport celle-ci est définie par :
Code :
new java.io.File($P{BaseDir},"logo.jpg")
BaseDir étant de type String est correspondant au chemin suivant /report/jasper/image dans mon application WEB.

Dans ma servlet j'utilise ceci :
Code :
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
28
29
30
31
32
 
response.setContentType("text/html");
response.setHeader("Content-disposition", "filename="+realName+".html");
 
JRHtmlExporter exporter = new JRHtmlExporter();
 
exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, servletOutputStream);
 
exporter.setParameter(JRHtmlExporterParameter.OUTPUT_WRITER,out);
HashMap<Object, Object> fontMap = new HashMap<Object, Object>();
 
Map<String, Object> imagesMap = new HashMap<String, Object>();
imagesMap.put("logo.jpg", getServletContext().getRealPath("/report/jasper/image/logo.jpg"));
 
request.getSession().setAttribute("IMAGES_MAP",imagesMap);             
exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP,imagesMap);
 
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"/report/jasper/image?image=");
exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,getServletContext().getRealPath("/report/jasper/image"));
 
exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,Boolean.TRUE);
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, "px");
exporter.setParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
exporter.setParameter(JRHtmlExporterParameter.FONT_MAP, fontMap);
 
exporter.exportReport();
 
servletOutputStream.flush();
servletOutputStream.close();
Mon image se situe donc dans /report/jasper/image et se nomme logo.jpg.

Le problème c'est que lors de la génération du code HTML j'ai :
Code :
<img src="/report/jasper/image?image=img_0_0_0" border="0" style="width: 70px" alt=""/>
Donc le problème vient forcément de la mais je ne sais pas comment faire pour y remédier.

J'accepte toutes les bonnes volontés
Loujou est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h22.


 
 
 
 
Partenaires

Hébergement Web