Package javax.print.attribute

Examples of javax.print.attribute.HashDocAttributeSet


            // Print is sent
            DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType);
            InputStream bais = new ByteArrayInputStream(baos.toByteArray());

            DocAttributeSet docAttributeSet = new HashDocAttributeSet();
            List<Object> docAttributes = UtilGenerics.checkList(serviceContext.remove("docAttributes"));
            if (UtilValidate.isNotEmpty(docAttributes)) {
                for (Object da : docAttributes) {
                    Debug.logInfo("Adding DocAttribute: " + da, module);
                    docAttributeSet.add((DocAttribute) da);
                }
            }

            Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet);
View Full Code Here


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

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

        daset.add(MediaSizeName.ISO_A4);

        try {
            DocFlavor df = DocFlavor.INPUT_STREAM.JPEG;
            InputStream fis = this.getClass().getResourceAsStream(
                    "/Resources/JPEG.jpg");
View Full Code Here

    public void testLookupPrintServices() {
        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

        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);

        try {
            services = PrintServiceLookup.lookupMultiDocPrintServices(
                    new DocFlavor[] { psFlavor }, aset);
            if (services != null && services.length > 0) {
View Full Code Here

            getClass().getResourceAsStream("/Resources/picture.gif");
    if (reader == null) {
        fail("/Resources/picture.gif resource is not found!");
    }
   
    DocAttributeSet aSet = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(reader, flavor, aSet);
   
    assertEquals(doc.getAttributes(), aSet);
    aSet.add(OrientationRequested.LANDSCAPE);
    aSet.add(MediaName.NA_LETTER_WHITE);
    assertEquals(doc.getAttributes(), aSet);
    assertEquals(doc.getDocFlavor(), DocFlavor.INPUT_STREAM.GIF);
    try {
        assertTrue(doc.getPrintData() instanceof java.io.InputStream);
        assertNull(doc.getReaderForText());
View Full Code Here

}

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

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

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

        daset.add(MediaSizeName.ISO_A4);

        try {
            DocFlavor df = DocFlavor.INPUT_STREAM.AUTOSENSE;
            InputStream fis = this.getClass().getResourceAsStream(
                    "/Resources/hello_ps.ps");
View Full Code Here

        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);

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

*/
public class getAttributes implements Testlet
{
  public void test(TestHarness harness)
  {
    HashDocAttributeSet set = new HashDocAttributeSet();
    set.add(Sides.DUPLEX);
    set.add(Compression.COMPRESS);
    set.add(OrientationRequested.LANDSCAPE);
   
    SimpleDoc doc =
      new SimpleDoc(new byte[100], DocFlavor.BYTE_ARRAY.GIF, set);
   
    DocAttributeSet set1 = doc.getAttributes();
View Full Code Here

            // Print is sent
            DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType);
            InputStream bais = new ByteArrayInputStream(baos.toByteArray());

            DocAttributeSet docAttributeSet = new HashDocAttributeSet();
            List docAttributes = (List) serviceContext.remove("docAttributes");
            if (UtilValidate.isNotEmpty(docAttributes)) {
                for (Object da : docAttributes) {
                    Debug.logInfo("Adding DocAttribute: " + da, module);
                    docAttributeSet.add((DocAttribute) da);
                }
            }

            Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet);
View Full Code Here

TOP

Related Classes of javax.print.attribute.HashDocAttributeSet

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.