Package javax.print

Examples of javax.print.DocFlavor


                        "Already printed. Need to create new DocPrintJob.");
            }
            busyFlag = true;
        }
       
        DocFlavor userDocDF = userDoc.getDocFlavor();

        /*
         * Checking if doc.DocFlavor is supported by the current
         * PrintService
         */
        if (!printService.isDocFlavorSupported(userDocDF)) {
            throw new PrintException("Doc flavor \'" + userDocDF
                    + "\' is not supported");
        }

        /*
         * Checking if doc.DocFlavor is supported directly by osClent. If it
         * is not: - get StereamPrintServiceFactory for doc.DocFlavor -
         * instantiate StreamPrintService - get PrintJob from it - run this
         * PrintJob in separate thread
         */
        printClient = printService.getPrintClient();
        if (printService.isDocFlavorSupportedByClient(userDocDF)) {
            printClient.print(userDoc, printRequestAS);
        } else {
            try {
                Doc clientDoc = userDoc;
                PipedOutputStream spsOutStream = new PipedOutputStream();
                PipedInputStream clientInputStream = new PipedInputStream(
                        spsOutStream);

                DocFlavor newFlavor = null;
                StreamPrintServiceFactory spsf = null;
                DocFlavor clientFlavors[] = printClient
                        .getSupportedDocFlavors();

                for (int i = 0; i < clientFlavors.length; i++) {
                    StreamPrintServiceFactory[] factories = StreamPrintServiceFactory
                            .lookupStreamPrintServiceFactories(userDocDF,
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

    /*
     * opposite to java2ipp() method
     */
    private DocFlavor ipp2java(DocFlavor ippDocFlavor) {
        DocFlavor pDocFlavor = ippDocFlavor;
        String mime = ippDocFlavor.getMimeType();

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

    private boolean isDocFlavorSupported(DocFlavor flavor) {
        if (flavor == null) {
            throw new NullPointerException("DocFlavor flavor is null");
        }

        DocFlavor clientFlavors[] = getSupportedDocFlavors();
        for (int i = 0; i < clientFlavors.length; i++) {
            if (clientFlavors[i].equals(flavor)) {
                return true;
            }
        }
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 {
       
        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

        if (flavor == null) {
            return client.getSupportedAttributeValues(category, flavor,
                    attributes);
        }

        DocFlavor clientFlavors[] = client.getSupportedDocFlavors();
        if (isDocFlavorSupportedByClient(flavor, clientFlavors)) {
            return client.getSupportedAttributeValues(category, flavor,
                    attributes);
        }
        /*
 
View Full Code Here

        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

TOP

Related Classes of javax.print.DocFlavor

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.