Package javax.print.attribute.standard

Examples of javax.print.attribute.standard.DocumentName


        for (int i = 0; i < services.length; i++) {
            System.out.println("\t" + services[i].getName());
        }

        DocAttributeSet dset = new HashDocAttributeSet();
        dset.add(new DocumentName("print doc name", Locale.US));

        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(new Copies(3));
        aset.add(MediaName.ISO_A4_WHITE);
        aset.add(new RequestingUserName("ichebyki", Locale.US));

        try {
            PrintService serv = services[0];
            InputStream stream;
            DocFlavor flavor;
            DocPrintJob job;
            Doc doc;
            URL url;
            Reader rdr;

            try {
                flavor = DocFlavor.URL.PDF;//TEXT_HTML_HOST;
                if (serv.isDocFlavorSupported(flavor)) {
                    aset.add(new JobName(flavor.toString(), Locale.US));
                    dset.add(new DocumentName(http_ps, Locale.US));
                    job = serv.createPrintJob();
                    url = new URL(http_ps);
                    doc = new SimpleDoc(url, flavor, dset);
                    System.out.println("\nPrinting on "
                            + job.getPrintService().getName() + "...");
                    job.print(doc, aset);
                    System.out.println("File '" + http_ps + "' was printed as "
                            + flavor.getRepresentationClassName());
                }

                flavor = DocFlavor.URL.GIF;
                if (serv.isDocFlavorSupported(flavor)) {
                    aset.add(new JobName(flavor.toString(), Locale.US));
                    dset.add(new DocumentName(http_gif, Locale.US));
                    job = serv.createPrintJob();
                    url = new URL(http_gif);
                    doc = new SimpleDoc(url, flavor, dset);
                    System.out.println("\nPrinting on "
                            + job.getPrintService().getName() + "...");
                    job.print(doc, aset);
                    System.out.println("File '" + http_gif + "' was printed as "
                            + flavor.getRepresentationClassName());
                }
            } catch (PrintException e1) {
                e1.printStackTrace();
            }

            flavor = DocFlavor.READER.TEXT_PLAIN;
            if (serv.isDocFlavorSupported(flavor)) {
                aset.add(new JobName(flavor.toString(), Locale.US));
                dset.add(new DocumentName(file_txt, Locale.US));
                job = serv.createPrintJob();
                rdr = new InputStreamReader(getClass().getResourceAsStream(
                        file_txt));
                doc = new SimpleDoc(rdr, flavor, dset);
                System.out.println("Printing on "
                        + job.getPrintService().getName() + "...");
                job.print(doc, aset);
                System.out.println("File '" + file_txt + "' was printed as "
                        + flavor.getRepresentationClassName());
            }

            flavor = DocFlavor.INPUT_STREAM.GIF;
            if (serv.isDocFlavorSupported(flavor)) {
                aset.add(new JobName(flavor.toString(), Locale.US));
                dset.add(new DocumentName(file_gif, Locale.US));
                job = serv.createPrintJob();
                stream = getClass().getResourceAsStream(file_gif);
                doc = new SimpleDoc(stream, flavor, dset);
                System.out.println("\nPrinting on "
                        + job.getPrintService().getName() + "...");
                job.print(doc, aset);
                System.out.println("File '" + file_gif + "' was printed as "
                        + flavor.getRepresentationClassName());
            }

            flavor = DocFlavor.BYTE_ARRAY.JPEG;
            if (serv.isDocFlavorSupported(flavor)) {
                aset.add(new JobName(flavor.toString(), Locale.US));
                dset.add(new DocumentName(file_gif, Locale.US));
                job = serv.createPrintJob();
                stream = getClass().getResourceAsStream(file_gif);
                byte[] gif_buf;
                byte[] buf = new byte[1024];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here


                    MediaSizeName.ISO_A2,
                    MediaSizeName.ISO_A3,
                    new Destination(uri1),
                    new Destination(uri2),
                    new Destination(uri3),
                    new DocumentName("xyz", Locale.US),
                    new JobName("xyz", Locale.US),
                    new RequestingUserName("xyz", Locale.US),
                    Sides.DUPLEX,
                    Sides.ONE_SIDED,
                    Sides.TUMBLE,
View Full Code Here

                AttributeSet attrs = new HashAttributeSet();
                attrs.add(Finishings.EDGE_STITCH);
                attrs.add(MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
                attrs.add(new Destination(uri));
                attrs.add(new DocumentName("Doc X", Locale.US));
                attrs.add(new JobName("Job Y", Locale.US));
                attrs.add(new RequestingUserName("User Z", Locale.US));

                for (int j = 0; j < flavors.length; j++) {
                    if (services[i].isDocFlavorSupported(flavors[j])) {
View Full Code Here

        /* if no job name supplied use doc name (if supplied), if none and
         * its a URL use that, else finally anything .. */
        if (jobAttrSet.get(JobName.class) == null) {
            JobName jobName;
            if (docSet != null && docSet.get(DocumentName.class) != null) {
                DocumentName docName =
                    (DocumentName)docSet.get(DocumentName.class);
                jobName = new JobName(docName.getValue(), docName.getLocale());
                jobAttrSet.add(jobName);
            } else {
                String str = "JPS Job:" + doc;
                try {
                    Object printData = doc.getPrintData();
View Full Code Here

        /* if no job name supplied use doc name (if supplied), if none and
         * its a URL use that, else finally anything .. */
        if (jobAttrSet.get(JobName.class) == null) {
            JobName jobName;
            if (docSet != null && docSet.get(DocumentName.class) != null) {
                DocumentName docName =
                    (DocumentName)docSet.get(DocumentName.class);
                jobName = new JobName(docName.getValue(), docName.getLocale());
                jobAttrSet.add(jobName);
            } else {
                String str = "JPS Job:" + doc;
                try {
                    Object printData = doc.getPrintData();
View Full Code Here

                                }
                            }), Locale.US) };
        } else if (JobName.class.isAssignableFrom(category)) {
            return new Object[] { new JobName("Java print job", Locale.US) };
        } else if (DocumentName.class.isAssignableFrom(category)) {
            return new Object[] { new DocumentName("Java print document",
                    Locale.US) };
        }
        return null;
    }
View Full Code Here

        } else if (RequestingUserName.class.isAssignableFrom(category)) {
            return new Object[] { new RequestingUserName("I.A.Muser", Locale.US) };
        } else if (JobName.class.isAssignableFrom(category)) {
            return new Object[] { new JobName("Foo print job", Locale.US) };
        } else if (DocumentName.class.isAssignableFrom(category)) {
            return new Object[] { new DocumentName("Foo document", Locale.US) };
        }
        return null;
    }
View Full Code Here

                                }
                            }), Locale.US) };
        } else if (JobName.class.isAssignableFrom(category)) {
            return new Object[] { new JobName("Java print job", Locale.US) };
        } else if (DocumentName.class.isAssignableFrom(category)) {
            return new Object[] { new DocumentName("Java print document",
                    Locale.US) };
        }
        return null;
    }
View Full Code Here

        } else if (RequestingUserName.class.isAssignableFrom(category)) {
            return new Object[] { new RequestingUserName("I.A.Muser", Locale.US) };
        } else if (JobName.class.isAssignableFrom(category)) {
            return new Object[] { new JobName("Foo print job", Locale.US) };
        } else if (DocumentName.class.isAssignableFrom(category)) {
            return new Object[] { new DocumentName("Foo document", Locale.US) };
        }
        return null;
    }
View Full Code Here

                                }
                            }), Locale.US) };
        } else if (JobName.class.isAssignableFrom(category)) {
            return new Object[] { new JobName("Java print job", Locale.US) };
        } else if (DocumentName.class.isAssignableFrom(category)) {
            return new Object[] { new DocumentName("Java print document",
                    Locale.US) };
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of javax.print.attribute.standard.DocumentName

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.