<p>I've got Postscript code/data (?) in memory (in a Java Tomcat webapp) that I'd like to send directly to a networked PS printer.  Is there an easy way (i.e. just popping open a port and sending the text) to print this, bypassing all of the O/S-specific drivers and stuff (and hopefully not even requiring extra jars)?  A link to example code showing how to do this?</p>

<p>Thanks,
Dave</p>

I am not sure you can do it without extra library.
This
example
shows you how to send the file to a network printer, but requieres an adobe library (based on commercial J2EE
Livecycle ES
though, so not a generic "free" solution...).
```
```
import com.adobe.livecycle.output.client.*;
import java.util.*;    
import java.io.File;    
import java.io.FileInputStream;    
import com.adobe.idp.Document;    
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;

public class SendToPrinter {

    public static void main(String[] args) {
        try{
            //Set LiveCycle ES service connection properties                            
            Properties ConnectionProps = new Properties();
            ConnectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");
            ConnectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");          
            ConnectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");
            ConnectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");
            ConnectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");
            //Create a ServiceClientFactory object
            ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);
            //Create an OutputClient object
            OutputClient outClient = new OutputClient(myFactory); 
            //Reference XML data that represents form data
            FileInputStream fileInputStream = new FileInputStream("C:\\Adobe\\Loan_data.xml"); 
            Document inputXML = new Document(fileInputStream);
            //Set print run-time options
            PrintedOutputOptionsSpec printOptions = new PrintedOutputOptionsSpec(); 
            printOptions.setPrinterURI("\\\\Printer1\\Printer");
            printOptions.setCopies(2);

            //Send a PostScript print stream to printer
            OutputResult outputDocument = outClient.generatePrintedOutput(
                    PrintFormat.PostScript,
                    "Loan.xdp",
                    "C:\\Adobe",
                    "C:\\Adobe",
                    printOptions,
                    inputXML); 

            //Write the results of the operation to OutputLog.xml
            Document resultData = outputDocument.getStatusDoc();
            File myFile = new File("C:\\Adobe\\OutputLog.xml");
            resultData.copyToFile(myFile);
        }
        catch (Exception ee)
        {
            ee.printStackTrace();
        }
    }
}
```
```