Précédent   Forum des professionnels en informatique > Java > Général Java > APIs
APIs Forum sur les API standard et API complémentaires. Avant de poster -> FAQ Java, Les meilleures API Java
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 13/12/2011, 12h22   #1
Membre régulier
 
Inscription : mai 2006
Messages : 285
Détails du profil
Informations forums :
Inscription : mai 2006
Messages : 285
Points : 83
Points : 83
Par défaut Intégration d'arabe dans un fichier PDF

Bonjour tout le monde,

J'utilise netBeans 6.9.1, je génère des PDF, je veux afficher des texte en arabe dans ce PDF.

j'ai fait pas mal de recherches sur le net, j'ai suivi ce lien :
http://www.developpez.net/forums/d47...rties-utf-8-a/.

Mais ça marche pas.

Avez-vous SVP des indications ou exemples pour ça?.

Merci d'avance.
amine1980 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2011, 14h01   #2
Expert Confirmé Sénior
 
Inscription : septembre 2004
Messages : 5 092
Détails du profil
Informations forums :
Inscription : septembre 2004
Messages : 5 092
Points : 7 020
Points : 7 020
Personne ne va deviner comment tu génères tes pdf.
thelvin est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2011, 16h25   #3
Membre régulier
 
Inscription : mai 2006
Messages : 285
Détails du profil
Informations forums :
Inscription : mai 2006
Messages : 285
Points : 83
Points : 83
Merci pour votre réponse.
Je génère mon PDF en utilisant Itext.
Voici mon code :

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
public static void main(String[] args) throws FileNotFoundException {
   Document document = new Document(PageSize.A4);
 
 
		try{
			PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
 
 
 
 
//			Ajout de l'entête gauche
			Paragraph para1 = new Paragraph();
			para1.add("Entete du fichier PDF");
			HeaderFooter header = new HeaderFooter(para1,false);
 
			header.setAlignment(HeaderFooter.ALIGN_LEFT);
                        document.setHeader(header);
 
 
 
//			Ajout du pied de page
			Paragraph para2 = new Paragraph();
			para2.add("Pied de page");
			HeaderFooter footer = new HeaderFooter(para2,false);
			footer.setAlignment(HeaderFooter.ALIGN_CENTER);
			document.setFooter(footer);
 
                        writer.close();
                        document.open();
                        document.newPage();
 
                        /*************************************************/
                        /*************************************************/
                        PdfPTable tableHaut = new PdfPTable(1);
                        PdfPCell cellHaut = new PdfPCell(new Paragraph("Docteur flan wled frtllan"));
                        cellHaut.setHorizontalAlignment(Cell.ALIGN_LEFT);
                        tableHaut.addCell(cellHaut);
                        document.add(tableHaut);
                        /*************************************************/
                        /**************************************************/
			//Image img = Image.getInstance("Workspace/win/WebContent/images/zoomold.jpg");
			//img.scalePercent(100);
			Phrase h1 = new Phrase("header 1");
			Phrase h2 = new Phrase("header 2");
			//HeaderFooter header = new HeaderFooter(h1,h2);
			//document.setHeader(header);
			Phrase f1 = new Phrase("footer 1");
			Phrase f2 = new Phrase("footer 2");
			//HeaderFooter footer = new HeaderFooter(f1,f2);
			//document.setFooter(footer);
			//document.add(header);
			//document.add(footer);
                        int numTransaction = 1560;
                        String titreEdTransaction = "l3onwan dyam transaction";
                        String numVoie = "30021";
                        String typeVoie ="9002";
                        String nomVoie = "Zen9at lbo3ara";
                        String codePostal = "20600";
                        String commune = "Bernoussi";
                        String prenomNego = "Rachid";
                        String nomNego = "AMINE";
			Font fontRed = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL, new Color(255,0,0));
			Font fontTitre =  new Font(Font.HELVETICA,Font.DEFAULTSIZE,Font.BOLD);
			Font fontLibelle =  new Font(Font.HELVETICA,8,Font.NORMAL);
			Phrase libNumTrans = new Phrase("Numéro de transaction :",fontLibelle);
			Phrase intNumTrans = new Phrase(String.valueOf(numTransaction),fontLibelle);
			Phrase titre = new Phrase("Photo du bien",fontRed);
			PdfPTable table = new PdfPTable(2);
			PdfPCell cell = new PdfPCell(new Paragraph(titreEdTransaction,fontTitre));
			Cell celltest = new Cell(cell);
			cell.setColspan(2);
			cell.setHorizontalAlignment(Cell.ALIGN_CENTER);
			cell.setVerticalAlignment(Cell.ALIGN_CENTER);
			celltest.setHeader(true);
			table.addCell(cell);
			table.addCell(libNumTrans);
			table.addCell(intNumTrans);
			table.addCell("Adresse : ");
			table.addCell(numVoie.trim()+", "+typeVoie.trim()+" "+nomVoie.trim()+", "+codePostal.trim()+" "+commune.trim());
			table.addCell("Négociateur : ");
			table.addCell(prenomNego.trim()+" "+nomNego.trim());
			table.addCell(titre);
			//table.addCell(img);
			document.add(table);
			PdfPTable tableCustomized = new PdfPTable(3);
			PdfPTable tableNested = new PdfPTable(6);
			Phrase type = new Phrase("Type :",fontLibelle);
			Phrase surface = new Phrase("Surface :",fontLibelle);
			Phrase venteloc = new Phrase("Vente / Location :",fontLibelle);
			tableNested.addCell(type);
			tableNested.addCell(surface);
			tableNested.addCell(venteloc);
			tableNested.addCell("Bureau");
			tableNested.addCell("5000 m²");
			tableNested.addCell("Vente");
			tableCustomized.setTotalWidth(40);
			PdfPCell cellule = new PdfPCell(new Paragraph("test table",fontTitre));
			cellule.setBackgroundColor(new Color(0,255,255));
			cellule.setBorder(0);
			tableCustomized.addCell(cellule);
			tableCustomized.addCell("fffff");
			tableCustomized.addCell("ddedede");
			tableCustomized.addCell("jryjyjtjtyjtjty");
			tableCustomized.addCell("ffhyjjuj");
			tableCustomized.addCell(tableNested);
			document.add(tableCustomized);
			PdfPTable tableDyn = new PdfPTable(2);
			tableDyn.setWidthPercentage(50);
			//tableDyn.setHorizontalAlignment(80);
			//tableDyn.setTotalWidth(25);
 
 
 
 
				Phrase numTrans = new Phrase("NUM_TRANSACTION::2",fontLibelle);
				PdfPCell celluleNumTrans = new PdfPCell(new Paragraph(numTrans));
				celluleNumTrans.setBackgroundColor(new Color(255,0,0));
				celluleNumTrans.setBorder(0);
				tableDyn.addCell(celluleNumTrans);
			        Phrase localCommune = new Phrase("LOCAL_COMMUNE::3",fontLibelle);
				 tableDyn.addCell(localCommune);
 
			document.add(tableDyn);
			document.close();
		} catch(DocumentException de){
			System.out.println("Pb PDF : "+de);
		}
	}
  }
J'ai écris directement l'arabe dans la class java mais ça pas marché .

Merci d'avance.
amine1980 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/12/2011, 09h20   #4
Membre Expert
 
Homme
Ingénieur développement logiciels
Inscription : septembre 2008
Messages : 730
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : septembre 2008
Messages : 730
Points : 1 394
Points : 1 394
Quand tu dis que ça ne marche pas, c'est à dire?
Qu'obtiens tu?
deathness est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/12/2011, 12h26   #5
Membre régulier
 
Inscription : mai 2006
Messages : 285
Détails du profil
Informations forums :
Inscription : mai 2006
Messages : 285
Points : 83
Points : 83
Je veux dire que lorsque j'écris l'arabe dans la class java, j'obtiens bien le document PDF mais vide, il n'écrit pas la chaine en arabe.

Merci d'avance.
amine1980 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 03h23.


 
 
 
 
Partenaires

Hébergement Web