Solved

How to open a PDF file from an Applet

Posted on 2001-08-10
8
419 Views
Last Modified: 2006-11-17
Hi

  Could someone give some sample on how to open
a PDF file from an Applet.

Any help is greatly appreciated.

Thanx

Dylan
0
Comment
Question by:dil_line
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Accepted Solution

by:
dviji earned 50 total points
ID: 6373475
If you want to open the pdf file from the Applet
use AppletContext.showDoumnent("pdf_url","_blank"). It will open that pdf file in a new window... for that same window and some other kinds try with other target attributes in the showdoument() method;

One more possiblity goto www.lowagie.com  and see any API available for pdf reading. [I think I saw some API for PDF generation... ;-))).. ]

Best of luck...

...dviji
0
 

Author Comment

by:dil_line
ID: 6373538
Thanx dviji

        It cannot find showDocument methd. Do I have to import anything ?

Thanx

Dylan
0
 
LVL 92

Expert Comment

by:objects
ID: 6374463
Get it from the getAppletContext() method in Applet
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 2

Expert Comment

by:vasan_sr
ID: 6379110
hi,
  see the code.....
package play.pdf;

import java.applet.*;
import java.awt.*;
import java.net.URL;
/**
 * Demonstrate how to view a PDF document from a Java applet.
 * Makes use of showDocument(), which is described in AppletContext.
 *
 * Assumptions:
 *
 * The applet must be run from a browser, such as Internet Explorer or Netscape Communicator.
 * The browser must have an Adobe Reader plug-in.
 * The technique does not work using appletviewer.
 *
 *
 * This type was created in VisualAge.
 *
 * @author Gerald Hurdle
 * @version 1.0
 */
public class PDFViewer extends Applet {
     Font font = new Font("Dialog", Font.BOLD, 24);
     String str = "PDF Viewer";
     int xPos = 5;
/**
 * Returns information about this applet.
 * @return a string of information about this applet
 */
public String getAppletInfo() {
     return "PDFViewer\n" +
          "\n" +
          "This type was created in VisualAge.\n" +
          "";
}
/**
 * Draws the text on the drawing area.
 * @param g the specified Graphics window
 */
public void paint(Graphics g) {
     g.setFont(font);
     g.setColor(Color.black);
     g.drawString(str, xPos, 50);
}
/**
 * Called to start the applet. You never need to call this method
 * directly, it is called when the applet's document is visited.
 * @see #init
 * @see #stop
 * @see #destroy
 */
public void start() {
     super.start();

     // insert any code to be run when the applet starts here
     try {
          URL url = new URL( "http://www.somecomputer.com/MyPDFDocument.pdf" );
          this.getAppletContext().showDocument( url, "_blank" );
     } catch (Exception e) {
          System.err.println( "Error: Could not display PDF document!" );
     }
}

0
 
LVL 3

Expert Comment

by:modder
ID: 6489683
Hello all,

dil_line is a duplicate account, and it has been closed.

Please advise as to who should get points for this.

modder
Community Support
0
 
LVL 92

Expert Comment

by:objects
ID: 6489849
I vote for dviji.
0
 
LVL 3

Expert Comment

by:modder
ID: 6489858
OK
0
 
LVL 92

Expert Comment

by:objects
ID: 6489868
Is that how democracy works here at ee :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question