IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AWT/Swing Java Discussion :

Problème avec le lancement des classes qui gèrent un fichier PDF


Sujet :

AWT/Swing Java

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2012
    Messages
    36
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Novembre 2012
    Messages : 36
    Points : 26
    Points
    26
    Par défaut Problème avec le lancement des classes qui gèrent un fichier PDF
    svp je suis entrain de finir mon application et quand je crée un fichier jar toutes les classes qui gèrent un fichier pdf ne veulent plus se lancer , sachant qu'elle se lance à travers un clique sur JMenuItem .
    (ces classes s'ouvrent bien avec eclipse)
    et voilà la méthode qui sert à gérer le fichier dont j'ai utiliser .

    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
    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
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
     
     
     
        public void reportPdf() throws IOException{
     
            String out = "nbr.pdf";
            Document document = new Document(PageSize.A4);
     
        	//------------------- connexion base de données ------------		
     
        	try {
        		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
     
            con = DriverManager.getConnection(url,"",""); 
            Statement requete = con.createStatement(); 
     
     
     
     
            try {
     
     
            	// etape 2:
                // creation du writer -> PDF ou HTML
                PdfWriter.getInstance(document, new FileOutputStream(out));
     
                // etape 3: Ouverture du document
                document.open();
     
                com.itextpdf.text.Font fontbold = FontFactory.getFont("Times-Roman", 18, Font.BOLD);
     
                com.itextpdf.text.Font font2 = FontFactory.getFont("Times-Roman", 14, Font.BOLD);
     
     
                // etape 4: Ajout du contenu au document
                document.addTitle("Office National Des Aéroport");
                document.addCreationDate();
                Paragraph p1 = new Paragraph("\nOffice National Des Aéroport ",fontbold);
                Paragraph p2 = new Paragraph("Bon de Réception N° : "+nbr.getSelectedItem()+" \n\n\n",font2);
                document.add(p1);
     
           //********** img   
              java.awt.Image awtImg = 
          			java.awt.Toolkit.getDefaultToolkit()
          				.createImage("icons/logo.gif");
     
              com.itextpdf.text.Image image2 = 
          			com.itextpdf.text.Image.getInstance(awtImg, null);
              image2.setAlignment(2);
          		document.add(image2);
         //**************** 		
     
          	  p2.setAlignment(1);document.add(p2);
              int i=1;
     
     
     		 ResultSet mvt_1 = requete.executeQuery("select * from mouvements where num_BR=\'"+nbr.getSelectedItem()+"\' and num_BS is null");
    mvt_1.next();
     
            	 int lignetableau =mvt_1.getRow()+1;
    String frn__s="";frn__s=mvt_1.getString("fr_raison_social"); 
     
    Paragraph p3 = new Paragraph("Fournisseur                : "+frn__s+"                                           N° Commande     : "+mvt_1.getString("n_commande")+"");
        document.add(p3);
     
    Paragraph p5 = new Paragraph("N° Bon Livraison        :                                                             Date Livraison      " +
    		":");
        document.add(p5);
     
    Paragraph p4 = new Paragraph("Date Réception          : "+mvt_1.getString("date_m")+" \n\n\n\n");
             document.add(p4);
     
     
     
            PdfPTable table = new PdfPTable(8);
     
     		table.setWidthPercentage(100); // Code 2
     		table.setHorizontalAlignment(Element.ALIGN_TOP);
     
             PdfPCell cell;
     
           	// Code 2
     		table.addCell("N° \n\n");
     		table.addCell("Article \n\n");
     		table.addCell("Prix unitaire \n\n");
     		table.addCell("Prix MP \n\n");
     		table.addCell("Qte reçue\n\n");
     		table.addCell("Qte stock \n\n");
     		table.addCell("Valeur stock \n\n");
     		table.addCell("Valeur \n\n");
     		//** table.addCell("row 1; cell 1");
     
     ResultSet mvt = requete.executeQuery("select * from mouvements where num_BR=\'"+nbr.getSelectedItem()+"\' and num_BS is null");
     
     
     		 while(mvt.next())
             {	
             cell = new PdfPCell( new Phrase(Integer.toString(i))) ;
             cell. setColspan(1) ; // an entire row
             table.addCell(cell);
     
             PdfPCell anotherCell;
             anotherCell = new PdfPCell( new Phrase(mvt.getString("designation_art")) );
             anotherCell.setColspan(1); // a second row
             table.addCell(anotherCell);
     
             PdfPCell anotherCell2;
             anotherCell2 = new PdfPCell( new Phrase(mvt.getString("prix_u")) );
             anotherCell2.setColspan(1); // a second row
              table.addCell(anotherCell2);
     
             PdfPCell prix_mp;
             prix_mp = new PdfPCell( new Phrase(mvt.getString("prix_m_p")) );
             prix_mp.setColspan(1); // a second row
             table.addCell(prix_mp);
     
             PdfPCell qte_e;
             qte_e= new PdfPCell( new Phrase(mvt.getString("qte_entree")));
             qte_e.setColspan(1); // a second row
             table.addCell(qte_e);
     
     
             PdfPCell qte_stock;
             qte_stock= new PdfPCell( new Phrase(mvt.getString("qte_stock")));
             qte_stock.setColspan(1); // a second row
             table.addCell(qte_stock);
     
     
     
             PdfPCell stk_val;
             stk_val= new PdfPCell( new Phrase(mvt.getString("val_stock")+""));
             stk_val.setColspan(1); // a second row
             table.addCell(stk_val);
     
     
             PdfPCell val;
             val= new PdfPCell( new Phrase(mvt.getString("valeur")+""));
            // val.setColspan(2); // a second row
             table.addCell(val);
     
     
     
     
            i++; 
             };
     
     
             document.add(table);
     
     
             Paragraph p6 = new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
             document.add(p6);
     
             LineSeparator UNDERLINE =
                     new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -2);document.add(UNDERLINE);
     
    Paragraph p15 = new Paragraph("Responsable Magasin :                                                                  Contrôle :");
                    	    document.add(p15);
     
    Paragraph p25 = new Paragraph("LAALAJ, Mlle/Mme NIAMA");document.add(p25);               	    
     
            }
     
            catch(DocumentException de) {
                System.err.println(de.getMessage());
     
            }
            catch(IOException ioe) {
                System.err.println(ioe.getMessage());
     
            }
     
            // etape 5: Fermeture du document
     
            document.close();
     
            System.out.println("Document '"+out+"' generated");
     
     
        	}
        	catch(Exception e1) {  System.out.println("Exception");  } 
        	finally { 
        	 try {con.close();} 
        	catch(SQLException e1) { System.out.println("db");} 
        	        } 
     
     
            Desktop desk = Desktop.getDesktop();
            desk.open(new File("nbr.pdf"));
        }

    svp aidez moi !!!

  2. #2
    Nouveau membre du Club
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2012
    Messages
    36
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Novembre 2012
    Messages : 36
    Points : 26
    Points
    26
    Par défaut
    pas de solution ???

  3. #3
    Membre éprouvé
    Inscrit en
    Mars 2006
    Messages
    848
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Mars 2006
    Messages : 848
    Points : 1 078
    Points
    1 078
    Par défaut
    Citation Envoyé par dimateo_2012 Voir le message
    les classes qui gèrent un fichier pdf ne veulent plus se lancer
    Bonjour,

    peux-tu être plus précis?
    - As-tu une erreur?
    - L'action ne provoque rien?
    - L'application crashe?

    Cela nous permettras de nous orienter dans ton code.

Discussions similaires

  1. Problème avec le lancement des plugins RCP sous Kepler (4.3)
    Par PA510024 dans le forum Eclipse Platform
    Réponses: 1
    Dernier message: 26/06/2013, 19h14
  2. Problème avec des classes qui etendent la classe View
    Par amsagitos dans le forum Composants graphiques
    Réponses: 0
    Dernier message: 14/09/2011, 22h14
  3. Réponses: 8
    Dernier message: 12/01/2011, 19h00
  4. Réponses: 2
    Dernier message: 04/01/2007, 16h48
  5. [Débutant] J'ai un problème avec la compilation des classes
    Par Paulinho dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 19/11/2005, 14h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo