Printing from Applets

Printing from Applets

I am trying to construct an applet that accepts data from the user and performs several calculations on that data.I would like to give the capability to print out the results of the calculation in a form. The template for the form will reside on the applet’s server. Is there any way to take the information given by the user and the results of the calculation and insert them into the form, and then print the form to the users local printer? I was thinking that I could implement a client/server to do this but am not quite sure about this.

Java does not provide any support for printing at this point. Printer access may be provided in future releases of Java but there is no standard platform-independent way to print from Java applets or Java applications today.

This probably has as much to do with the multitude of printing software and printers out there as it does with the many ways operating systems handle printing. If Java were to support one, it would have to support all of them in order to remain truly cross-platform.

Even if there were a way to print from Java, applets probably wouldn’t be allowed to print simply because applet access to local devices and files is strictly forbidden for security reasons. Imagine a malicious applet that started printing garbage to the user’s local printer as soon as it was loaded from the Net. It might steal fonts out of your printer, interfere with the existing print jobs, or print tons and tons of annoying advertisements without your knowing where they came from.

You might be able to create a standalone Java application for printing to a particular device on a given operating system, but it’s sure to be platform dependent. For example, if there’s a way to get to the parallel or serial port on your system through a file name, say /dev/ttya on UNIX systems, or lpt1 on wintel systems, you can certainly open a connection to the printer through the parallel or serial port file name and feed the text or postscript data to it, but there is no way for the app to know if it’s talking to a printer or to a modem. Here’s how that might look in Java:

        import*;        PrintStream printer = new PrintStream(new FileOutputStream(“/dev/ttya”));        for (int i = 0; i < lineCount; i++)                 printer.println(line[i]);

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as