Bonjour,

J'ai un problème de faire des documents PDF. En fait je me suis inspiré de la page suivante: http://java.developpez.com/faq/xml/?page=xslt. Il semble très facile de l'utiliser (il y a un exemple de tableau comme j'ai besoin). Par contre j'ai un problèle avec l'ajout des références (les lignes mis en commentaire).

Mon code est le suivant
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
//using javax.xml.parsers; 
//using org.w3c.dom;
using System.CodeDom;
//using org.xml.sax; 
 
//using javax.xml.transform; 
//using javax.xml.transform.sax; 
//using javax.xml.transform.dom; 
//using javax.xml.transform.stream; 
//using java.io;
using System.IO;
//using java.util;
 
//using org.apache.fop.apps.Driver;
 
 
namespace TestPdf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                creerPDF("sudoku.xml", "Modele.xsl", "Sudoku.pdf");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 
        public void creerPDF(String xml, String xsl, String pdf)
        {
		    // création du résultat (pdf)
		    Driver driver = new Driver();
		    driver.setRenderer(Driver.RENDER_PDF);
		    driver.setOutputStream(new java.io.FileOutputStream(pdf));
		    Result resultat = new SAXResult(driver.getContentHandler());
 
		    // récupération de la source xml
		    Source source = new StreamSource(xml);
 
		    // création du transformer en fonction du xsl
		    Source style = new StreamSource(xsl);
		    TransformerFactory transformerFactory = TransformerFactory.newInstance();
		    Transformer transformer = transformerFactory.newTransformer(style);
 
		    // transformation
		    transformer.transform(source, resultat);
	    }
    }
}
si quelqu'un pourrait me dire comment faire les importations de ces classes, ce serait très sympa