Package javax.print

Examples of javax.print.DocFlavor$SERVICE_FORMATTED


        if (flavor == null) {
            return client
                    .isAttributeValueSupported(attrval, flavor, attributes);
        }

        DocFlavor clientFlavors[] = client.getSupportedDocFlavors();
        if (isDocFlavorSupportedByClient(flavor, clientFlavors)) {
            return client
                    .isAttributeValueSupported(attrval, flavor, attributes);
        }
View Full Code Here


     *  If there is a DocFlavor that supported by PrintClient and by
     *  StreamPrintService, the method returns PrintClient's one only.
     */

    public DocFlavor[] getSupportedDocFlavors() {
        DocFlavor clientFlavors[] = client.getSupportedDocFlavors();
        ArrayList flavors = new ArrayList();

        /*
         * Putting all PrintClient's supported flavors (except
         * internal flavors) into list of flavors supported by
View Full Code Here

    /*
     * Checks, whether specified falvor is supported by
     * PrintClient or not.
     */
    boolean isDocFlavorSupportedByClient(DocFlavor flavor) {
        DocFlavor clientFlavors[] = client.getSupportedDocFlavors();
        for (int i = 0; i < clientFlavors.length; i++) {
            if (clientFlavors[i].equals(flavor)) {
                return true;
            }
        }
View Full Code Here

    public String getOutputFormat() {
        return mimeType;
    }
   
    public DocFlavor[] getSupportedDocFlavors() {
        DocFlavor copy_supportedDocFlavors[]
                               = new DocFlavor[supportedDocFlavors.length];
        for (int i = 0; i < supportedDocFlavors.length; i++) {
            copy_supportedDocFlavors[i] = supportedDocFlavors[i];
        }
        return copy_supportedDocFlavors;
View Full Code Here

 
    public void print(Doc doc, PrintRequestAttributeSet attributes)
            throws PrintException {
       
        Object data;
        DocFlavor docflavor;
        String docflavorClassName;
        Image image = null;
        int x = 0;
        int y = 0;
        int width;
        int height;
        int iWidth;
        int iHeight;       
        int newWidth;
        int newHeight;
        float scaleX;
        float scaleY;
       
        synchronized (this) {
            if (action) {
                throw new PrintException("printing is in action");
            }
            action = true;
        }

        try { // for finally block. To make action false.

            docflavor = doc.getDocFlavor();
            try {
                data = doc.getPrintData();
            } catch (IOException ioexception) {
                throw new PrintException("no data for print: "
                        + ioexception.toString());
            }           
            if (docflavor == null) {
                throw new PrintException("flavor is null");
            }
            if (!begetPrintService.isDocFlavorSupported(docflavor)) {
                throw new PrintException("invalid flavor :"
                        + docflavor.toString());
            }

            docflavorClassName = docflavor.getRepresentationClassName();

            if (docflavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
                docflavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
                docflavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
                docflavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
                docflavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
                docflavor.equals(DocFlavor.BYTE_ARRAY.PNG)) {               
                try {
                    image = readImage(doc.getStreamForBytes());
                } catch (IOException ioe) {
                    throw new PrintException(ioe);
                }
            } else if (docflavor.equals(DocFlavor.URL.GIF) ||
                       docflavor.equals(DocFlavor.URL.JPEG) ||
                       docflavor.equals(DocFlavor.URL.PNG)) {
                URL url = (URL) data;
                try {
                    image = readImage(url.openStream());
                } catch (IOException ioe) {
                    throw new PrintException(ioe);
                }
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)){
                Printable printable = (Printable)data;
                print(printable, null);
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE)) {
                Pageable pageable = (Pageable)data;
                print(null, pageable);
            } else {
                throw new PrintException("Wrong DocFlavor class: "
                        + docflavorClassName);
View Full Code Here

     * javax.print.attribute.PrintRequestAttributeSet)
     */
    public void print(Doc doc, PrintRequestAttributeSet attributes)
            throws PrintException {
        synchronized (this) {
            DocFlavor flavor = doc.getDocFlavor();
            if (flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
                flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT) ||
                flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
                flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
                flavor.equals(DocFlavor.BYTE_ARRAY.AUTOSENSE) ||
                flavor.equals(DocFlavor.URL.AUTOSENSE)) {
                InputStream data = null;
                try {
                    if (flavor.equals(DocFlavor.URL.POSTSCRIPT)) {
                        data = ((URL)doc.getPrintData()).openStream();
                    } else {
                        data = doc.getStreamForBytes();
                    }
                } catch (IOException ioe) {
                    throw new PrintException(
                            "Can't read data from document souce");
                }
                int printerID = startDocPrinter(serviceName,
                        convertAttributes(attributes, flavor),
                        getJobName(attributes), getDestination(attributes));
                if (printerID != 0) {
                    byte[] buffer = new byte[10240];
                    try {
                        int bytesRead = data.read(buffer);
                        while (bytesRead >= 0) {
                            if (!writePrinter(buffer, bytesRead, printerID)) {
                                endDocPrinter(printerID);
                                throw new PrintException(
                                        "Can't send data to printer");
                            }
                            bytesRead = data.read(buffer);
                        }
                    } catch (IOException ioe) {
                        throw new PrintException(
                                "Can't read print data from Doc");
                    }
                    if (!endDocPrinter(printerID)) {
                        throw new PrintException("Can't finish job normally");
                    }
                } else {
                    throw new PrintException("Can't start printing");
                }
            } else if (flavor.getMimeType().toLowerCase().equals(
                           "internal/postscript") &&
                       flavor.getRepresentationClassName().equals(
                           "java.io.InputStream")) {
                InputStream data = null;
                try {
                    data = (InputStream)doc.getPrintData();
                } catch (IOException ioe) {
View Full Code Here

    public String getName() {
        return "Convert source to Postscript language";
    }

    public DocFlavor[] getSupportedDocFlavors() {
        DocFlavor copy_supportedDocFlavors[]
                       = new DocFlavor[supportedDocFlavors.length];
        for (int i = 0; i < supportedDocFlavors.length; i++) {
            copy_supportedDocFlavors[i] = supportedDocFlavors[i];
        }
        return copy_supportedDocFlavors;
View Full Code Here

    public void print(Doc doc, PrintRequestAttributeSet attributes)
            throws PrintException {
        synchronized (this) {
            doVerbose(1, "Print " + doc.toString());
            try {
                DocFlavor df = doc.getDocFlavor();
                if (!(df instanceof DocFlavor.INPUT_STREAM
                        || df instanceof DocFlavor.BYTE_ARRAY
                        || df instanceof DocFlavor.CHAR_ARRAY
                        || df instanceof DocFlavor.STRING
                        || df instanceof DocFlavor.READER || df instanceof DocFlavor.URL)) {
                    throw new PrintException("Doc flavor "
                            + df.getRepresentationClassName()
                            + " is not supported yet");
                }

                HashAttributeSet as = new HashAttributeSet();
                DocAttributeSet das;
View Full Code Here

            throws PrintException {
        IppDocument document;
        IppResponse response;
        IppAttributeGroupSet agroupset;
        Attribute[] attrs;
        DocFlavor df = doc.getDocFlavor();
        String docname = doc.toString();

        try {
            document = new IppDocument(docname, java2ipp(df).getMimeType(), doc
                    .getPrintData());
View Full Code Here

     *      && printer supports mimetype application/ps
     * then
     *      we change mimetype of docflavor to application/ps
     */
    private DocFlavor java2ipp(DocFlavor pDocFlavor) {
        DocFlavor ippDocFlavor = pDocFlavor;
        String mime = pDocFlavor.getMimeType();

        /*
         * SPECIAL processing application/ps
         */
 
View Full Code Here

TOP

Related Classes of javax.print.DocFlavor$SERVICE_FORMATTED

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.