Yes this question is cf related. I'm using cf 4.5 on win2k workstation.

I tested the printgif.java file in the java 2 print api documentation.
Worked fine from my workstation to a network printer. using this code I
wrote a cfx custom tag to do the same (print gif files from the cf server
to a network printer). when i run the cfx tag it executes correctly but
does not print ?? I setup a listener for the print job and it says that
the job completes correctly ??? What am I missing ??

My question -: if java code executes correctly why doesn't the same code
work rolled up in a cfx tag? I have played with security issues for the cf
service (logon) and the printer (access) with no luck.

The stipped down code I'm using is below. The cfx tag is called like this

<cfx_gifPrint file="c:\myfile.gif" debug="yes">

Any ideas greatly appreciated.
Rod

>> gifPrint.java

/*
 * File:           gifPrint.java
 * Date:           26 May 2003  18:57
 *
 * @author  Rod Higgins
 * @version 0.1
 */

import com.allaire.cfx.*;
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;

public class gifPrint implements CustomTag {  
    public void processRequest(com.allaire.cfx.Request request,
com.allaire.cfx.Response response) throws java.lang.Exception {
        if(request.attributeExists("file")) {
            /* Use the pre-defined flavor for a GIF from an InputStream */
            DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
            /* Create a set which specifies how the job is to be printed
*/
            PrintRequestAttributeSet aset = new
HashPrintRequestAttributeSet();
            aset.add(MediaSizeName.NA_LETTER);
            aset.add(new Copies(1));
            /* Locate print services which can print a GIF in the manner
specified */
            PrintService[] pservices =
PrintServiceLookup.lookupPrintServices(flavor, aset);
            if (pservices.length > 0) {
                /* Create a Print Job */
                DocPrintJob printJob = pservices[0].createPrintJob();
                /* Create a Doc implementation to pass the print data */
                try {
                    response.writeDebug("File name passed in -: " +
request.getAttribute("file") + "<br>");
                    FileInputStream fis = new
FileInputStream(request.getAttribute("file"));
                    Doc doc = new SimpleDoc(fis, flavor, null);
                        /* Print the doc as specified */
                        try {
                            printJob.print(doc, aset);
                        } catch (PrintException e) { 
                            response.writeDebug("Print exception. Message
details -: " + e.getMessage());
                        }                    
                } catch (FileNotFoundException e) { 
                    response.writeDebug("File Not Found exception. Message
details -: " + e.getMessage());
                } catch (IOException ie) { 
                    response.writeDebug("I/O exception. Message details -:
" + ie.getMessage());
                }
            } else {
                response.writeDebug("No suitable printers");
            }
        }
    }
}

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to