Getting PDF file from Java Applet - java

I have generated a PDF object from scratch using PDFjet in a Java Applet i.e. I did NOT generate it on the server. But how can I invoke a "file download" prompt to serve this PDF without sending it to the server? I do not have a HTTPRequest or response.

There are two options I can think of for saving the document to disk.
Digitally sign the applet, get the user to accept the trusted code when prompted, offer the user a file chooser to specify a location, then save it to that location.
Use the JNLP API files services to do basically the same thing.

Related

how to read and save a server-side pdf with adobe in a client-side web browser? (plugin, applet / java servlet, ...)

My need is:
read a pdf present on a server to display it in a web browser
save the modifications of the pdf (made by the user) on the server
Currently, I'm using an independent applet that uses a servlet to open a connection between the client and the server. This allows you to read and save the pdf as a byte stream.
I need to do it with Adobe.
Do you know how I can do this? (Plugin, ...)
Thanks
environment: tomcat, java, jsp, internet explorer

Import html to lotus notes richtext using java

I would like to create a notes mail from some html source (with possibly inline image and attachments) using java through DIIOP. I tried to use mime item to do that, but sign and encrypt would need internet certs. So rich text seems to be the only choice, but I could not find any java API to import html into richtext. In notes client GUI, one can import from text/html. And also I noticed that MIME mail exported from inbox are "Itemized by DIIOP Server". Is there any way I can programmatically import html into lotus notes message so that sign and encrypt can be used with Lotus Notes internal certs.
Thanks and Regards,
Shing
You should be able to encrypt using Java via DIIOP, but you can't sign that way.
You need a private key in order to sign a message or document. The low-level Notes APIs expect the private key to be located in the current ID file for the session. When you are using DIIOP. Your Java code is running locally and it does not have access to your user ID file. The low-level Notes APIs don't run on the same machine that the Java is running on. There usually isn't even a Notes or Domino installation on the code where the Java code is running, so the code for the low-level APIs isn't even available to the JVM.
In a DIIOP configuraiton, the low-level Notes API code is running on the Domino server. The only ID file it has access to is the server ID file, and it will not allow you to sign using the server's private key.
Eventually find a solution, abeit rather hacky. create a document using MIME, then save to database, then close the session. The open a new session, and get the saved document, it is converted to richtext by the Domino Server, but there are some traces of MIME, export to DXL using DXLExporter. In the exported DXL, remove the items "MIME_Version" and "$MIMETrack". Inline image of type other than jpg and gif (png and gif) are not handled properly, have to play around the XML DOM a bit to fix it, then import the fixed DXL using DXLImporter, and there you have a converted Richtext document, rather like what you get from importing HTML file in Note Client GUI. Better than none.

How to upload and download a file with the given path(already known) without using html form in servlet using post method?

I know solution of the above problem using HTML form in which user chooses a file from computer and upload it and then download it but how to do it without using HTML with the already given path of file.
Thank you For your concern in Advance.
I assume the scenario is that the user accesses your server from a browser.
In this case you will not be able to access the file system given file paths. Only the user can grant access to certain files by selecting them in a file upload input.
If the user uses a mobile/desktop application that sends the file to your server, you must implement the upload in the app itself.

Read local file without open dialog (in browser)

There is any way (from browser) to read local file without open dialog?
Can be used: javascript, flash, or java.
Goal: when you paste text in WYSIWYG with images from MS Word, there will be links to image files. Like "file:///C:/Users/username/AppData/Local/Temp/msohtmlclip1/01/clip_image001.jpg". I want to read this files, upload to server and replace local path.
Accessing the disk contents from the browser without the user permission is a security risk. As such, to do that with Java you need your applet signed and the user allowing it to run.
A Java applet can do this, but it would need to be signed with an SSL certificate from a trusted authority, otherwise the applet would not be run with a security exception thrown.
You'd use any standard Java approach to loading and uploading the file (Apache Commons FileUtils and HttpClient?); if you're new to Java then there may be simpler solutions.

Generating/Downloading Docs in Java Applet

I currently have a finance calculator applet that at the users request generates a PDF of the information calculated for the user. When it is generated, the PDF is created locally, and a JFileChooser allows the user to move the PDF to the destination on their machine of their choosing.
A certificate is required for the JFileChooser to run. What can I do to deliver the PDF to the user as an alternative to the JFileChooser and signing the applet?
From the official Java Applet tutorial:
When launched by using JNLP, unsigned applets can also perform the
following operations:
* They can open, read, and save files on the client.
Check this out as an example.
If you have to stick to traditional applets, you should sign the jar, even if that means self-signing (I think in this case a warning is displayed, but the user can proceed).
Use this method:
URL url = new URL(getCodeBase().getProtocol(),
getCodeBase().getHost(),
getCodeBase().getPort(),
"/your_pdf_file");
getAppletContext().showDocument(url);
It would just prompt the user to download the file or view it inline
EDIT: This is only useful if the Server is generating the PDF and not the Client Applet

Categories