[Java] Mettre contenu pdf dans un JPanel

Cabernet -  
bravvve22 Messages postés 27 Statut Membre -
Bonjour,
Je suis sur un projet et je bloque sur un problème.
J'aimerais afficher le contenu d'un fichier .pdf dans un JPanel.
Est-il possible?
Y-a-t'il d'autres solutions plus efficace?
Merci
A voir également:

3 réponses

Cabernet
 
pitié :)
0
ray_fab
 
Bonjour,
afficher du pdf dans un JPanel?j'ai jamais entendu parler de ca que veux-tu faire exactement?explique c'est à ce moment la que je pourrais t'aider.
Bon courage!
0
bravvve22 Messages postés 27 Statut Membre 1
 
si tu présume afficher puis sortir voila la solution

	public PDFView() throws IOException
	{
		// set up the frame and panel
		getJFrame4().setVisible(true);

 
		// load a pdf from a byte buffer
		File file = new File(".//temp//page1.pdf");
		RandomAccessFile raf = new RandomAccessFile(file, "r");
		FileChannel channel = raf.getChannel();
		ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel
				.size());
		pdffile = new PDFFile(buf);
 
		// show the first page
		goToPage(1);
	}
	
	public void loadPdf(File file) throws IOException
	{

		// load a pdf from a byte buffer
		RandomAccessFile raf = new RandomAccessFile(file, "r");
		FileChannel channel = raf.getChannel();
		ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel
				.size());
		pdffile = new PDFFile(buf);
 
		// show the first page
		PDFPage page2 = pdffile.getPage(currentPage);
		jPanel3.showPage(page2);
	}
 
	public void goToPage(int nbpage) throws IndexOutOfBoundsException
	{
		if(nbpage<1||nbpage>pdffile.getNumPages())
			throw new IndexOutOfBoundsException("Invalid index requested :"+nbpage);
		PDFPage page = pdffile.getPage(nbpage);
		jPanel3.showPage(page);
	}
 


mai si tu veut afficher un fichier le modifier puis afficher une autre foi,la je suis a la recherche d'une solution moi aussi car

https://stackoverflow.com/questions/4179145/release-java-file-lock-in-windows
0