Examples of HashDocAttributeSet


Examples of javax.print.attribute.HashDocAttributeSet

}

public void testHashDocAttributeSet() {
    startTest("HashDocAttributeSet class testing...");

    DocAttributeSet set1 = new HashDocAttributeSet();
    DocAttributeSet set2 =
        new HashDocAttributeSet(OrientationRequested.LANDSCAPE);
    DocAttributeSet set3 = new HashDocAttributeSet(set2);
    DocAttribute [] arr = {OrientationRequested.LANDSCAPE,
                           MediaName.NA_LETTER_WHITE};
    DocAttributeSet set4 = new HashDocAttributeSet(arr);
    Attribute [] attrArr;

    assertTrue(set1.isEmpty());
    assertFalse(set2.isEmpty());
    assertTrue(set3.equals(set2));
    assertFalse(set3.equals(set1));
    set3.clear();
    assertEquals(set3, set1);
    set3.add(OrientationRequested.LANDSCAPE);
    set3.add(MediaName.NA_LETTER_WHITE);
    assertTrue(set3.containsKey(OrientationRequested.LANDSCAPE.getClass()));
    assertFalse(set2.containsKey(MediaName.NA_LETTER_WHITE.getClass()));
    assertTrue(set3.containsValue(OrientationRequested.LANDSCAPE));
    assertFalse(set3.containsValue(OrientationRequested.PORTRAIT));
    assertFalse(set3.containsValue(PrintQuality.DRAFT));
    assertEquals(set1.size(), 0);
    assertEquals(set2.size(), 1);
    assertEquals(set3.size(), 2);
    assertTrue(set4.equals(set3));
    assertEquals(set3.get(OrientationRequested.PORTRAIT.getClass()),
                 OrientationRequested.LANDSCAPE);
    assertFalse((set3.get(OrientationRequested.PORTRAIT.getClass()))
            .equals(OrientationRequested.PORTRAIT));
    set1.addAll(set3);
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

        System.out.println("Print services:");
        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

Examples of javax.print.attribute.HashDocAttributeSet

        DocFlavor psFlavor = DocFlavor.INPUT_STREAM.GIF;
        MultiDocPrintService[] services;
        FileInputStream fis;
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        aset.add(new Copies(2));
        aset.add(MediaSizeName.ISO_A4);
        daset.add(MediaName.ISO_A4_WHITE);
        daset.add(Sides.TWO_SIDED_LONG_EDGE);

        services = PrintServiceLookup.lookupMultiDocPrintServices(
                new DocFlavor[] { psFlavor }, aset);
        if (services != null && services.length > 0) {
            fis = new FileInputStream("/Resources/1M.GIF");
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

    public void testPrintJpeg() throws Exception {
        System.out.println("======== START PrintJpegTest ========");

        PrintService[] services;
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        daset.add(MediaSizeName.ISO_A4);

        DocFlavor df = DocFlavor.INPUT_STREAM.JPEG;
        InputStream fis = this.getClass().getResourceAsStream(
                "/Resources/JPEG.jpg");
        services = PrintServiceLookup.lookupPrintServices(df, aset);
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

    public void testLookupPrintServices() throws Exception {
        System.out.println("======== START LookupPrintServicesTest ========");

        PrintService[] services;
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        Object[][] filetoprint = { { "/Resources/JPEG.jpg",
                DocFlavor.INPUT_STREAM.JPEG },
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

    public void testPrintAutosense() throws Exception {
        System.out.println("======== START PrintAutosenseTest ========");

        PrintService[] services;
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        daset.add(MediaSizeName.ISO_A4);

        DocFlavor df = DocFlavor.INPUT_STREAM.AUTOSENSE;
        InputStream fis = this.getClass().getResourceAsStream(
                "/Resources/hello_ps.ps");
        services = PrintServiceLookup.lookupPrintServices(df, null);
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

        DocFlavor psFlavor = DocFlavor.INPUT_STREAM.GIF;
        PrintService service;
        InputStream fis;
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        HashDocAttributeSet daset = new HashDocAttributeSet();
        DocPrintJob pj;
        Doc doc;

        aset.add(new Copies(2));
        aset.add(MediaSizeName.ISO_A4);
        daset.add(MediaName.ISO_A4_WHITE);
        daset.add(Sides.TWO_SIDED_LONG_EDGE);

        service = PrintServiceLookup.lookupDefaultPrintService();
        if (service != null) {
            if (service.isDocFlavorSupported(psFlavor)) {
                if (service.getUnsupportedAttributes(psFlavor, aset)==null) {
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

    if (LOG.isDebugEnabled()) {
      LOG.debug("Printing using printer '" + this.printServiceExecutor.getPrintService().getName() + "'.");
    }

  DocAttributeSet das = new HashDocAttributeSet();
    das.add(Chromaticity.MONOCHROME);

    Object payload = message.getPayload();

    final Doc doc = new SimpleDoc(message.getPayload(), docFlavor, das);
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

   public DocFlavor getDocFlavor() {
       return DocFlavor.SERVICE_FORMATTED.PAGEABLE;
   }

   public DocAttributeSet getAttributes() {
       return new HashDocAttributeSet();
   }
View Full Code Here

Examples of javax.print.attribute.HashDocAttributeSet

      System.out.println("Imprimindo arquivo txt");
      // Defini��o de atributos do conte�do a ser impresso:
      DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
 
      // Atributos de impress�o do documento
      HashDocAttributeSet attributes = new HashDocAttributeSet();
     
      // InputStream apontando para o conte�do a ser impresso
      FileInputStream fi = new FileInputStream("teste.txt");
     
      // Cria um Doc para impress�o a partir do arquivo exemplo.txt
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.