Re: java.security.AccessControlException issue
Thanks Andrew,
so you think a newer sdk is the answer? I want to use the java
pdfviewer
because this site will be used to display answer sets for students.
The idea being I want
to wrap the pdf document and hide from the students the url (as much
as possible) disabling the prnting and
save function they wont be able to pass the answer sets to next years
students
here is the way i was trying to open the file:
File file = new File("http://128.233.22.97/test.pdf");
FileInputStream in = new FileInputStream(file);
acrobat.setDocumentInputStream(in);
here is the code I am trying ;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.applet.*;
import com.adobe.acrobat.*;
import java.lang.*;
import java.net.URL;
import java.util.*;
import java.net.MalformedURLException;
public class SampleReader extends Viewer {
public SampleReader() throws Exception {
}
public static void main(String args[]) {
Frame f = new Frame("Sample Acrobat Reader");
f.setLayout(new BorderLayout());
Label top = new Label("Acrobat Reader created using
adobe.Acrobat.Viewer", Label.CENTER);
top.setBackground(Color.red);
f.add(top, BorderLayout.NORTH);
f.add(new Label("Adobe Acrobat Reader - Alpha release - 1998",
Label.CENTER), BorderLayout.SOUTH);
try {
// Construct a acrobat object aka Acrobar Reader
// note that you must also call its activate
// method before you show the containing panel,
// in this case the frame object.
// The acrobat object is declared as final
// so that it could be referenced in the
// following windowClosing method.
final Viewer acrobat = new Viewer();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (acrobat != null) {
// The deactivate method will ensure that the
// acrobat.properties file is saved
// upon exit.
acrobat.deactivate();
}
System.exit(0);
}
});
try
{
// assumes that args[0] is the name of a file
//File file = new File(getParameter("pdffile"));
File file = new File("http://128.233.22.97/test.pdf");
FileInputStream in = new FileInputStream(file);
acrobat.setDocumentInputStream(in);
} catch (FileNotFoundException x) {
System.out.println("File not found!");
// The viewer will display a blank screen.
// You can then use the Viewer's pop-up menu
// to open a local or remote PDF file.
}
f.add(acrobat, BorderLayout.CENTER);
// you must call activate to enable the Viewer object
// to layout its sub-components and the further
initialization
// needed for it to be displayed.
acrobat.activate(); //WithoutBars();
} catch (Exception x) {
f.add(new Label("Unable to create an Acrobat Reader"),
"Center");
}
f.setSize(400, 400);
f.show();
}
}
On Mar 23, 8:51 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:
On Mar 24, 7:17 am, "merrittr" <merri...@gmail.com> wrote:
Yep I am using jdk 1.1.8 , that is what this applet requires (its the
adobe java pdf viewer).
Tom has covered most aspects relevant to
this problem, I'd just like to take it in
a slightly different direction for a moment.
1) The PDF viewer does not require '1.1.8',
it requires '1.1.8+'. That is an important
distinction, since the 1.1.8 VM's are becoming
as rare as the teeth of a hen.
2) It will almost certainly be able to accept
an URL as argument for the file.
3) If the PDF is coming off the server, it
should be possible to read it by URL, without
any special privileges.
4) ..and why would you want to use an applet
(as opposed to an application) for reading
PDF's off the local file system (i.e. not
available by URL from the server)?
Andrew T.