I need to launch the PDF reader and show a PDF file from an EJS java simulator.
I can do it-I have the code ready and working- but now I want to include the PDF file as a resource in the jar file. It is possible with sound and gif files (e.g, the SeeSaw simulator of Paco).
If I am not wrong, the OS PDF reader requires that the file is actually on your disk. Since the file will be on the JAR file, you need to extract it before trying to read it.
The org.colos.ejs.library.Simulation class has a couple of utilities for this. The first one is this:
/** Finds the file in the jar file and extracts it to a temporary file. The file will be deleted on exit */ static public File getResourceFile(String _filename);
/** Extracts the file to a target directory. The file will not be deleted on exit. */ static public File extractToDirectory(String _resourceString, File _targetDirectory, boolean _verbose);
/** Similar to the previous one, but changes the name to filename. */ static public File extractAs(String _resourceString, String filename, boolean _verbose);
I use it for my own internal purposes, but have not tried on PDFs.
If this does not work, I can try to do something new to help.
Vamos, que no tengo ni p... idea sobre como escribir el directorio de destino de la resourceString, y creo que ya estoy autolobotomizado de tanto buscarlo por los javadocs...
I have just now concocted some java code to extract a resource PDF file from the simulator's jar file, and then read it with the system default PDF reader.
I will put another tread with the complete solution with comments and a better code indentation than the actual.