Examples of PrintRequestAttributeSet


Examples of javax.print.attribute.PrintRequestAttributeSet

                .println("======= START LookupDefaultPrintServiceTest ======");

        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();
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

    private DocFlavor assignDocFlavor() throws Exception {
        return config.getDocFlavor();     
    }   

    private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        if (config.getCopies() >= 1) {
            printRequestAttributeSet.add(new Copies(config.getCopies()));
        } else {
            throw new PrintException("Number of print copies should be greater than zero");
        }
        printRequestAttributeSet.add(config.getMediaSizeName());
        printRequestAttributeSet.add(config.getInternalSides());
       
        return printRequestAttributeSet;
    }
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

   * @return
   */
  public static int isValidConfiguration(final PrintRequestAttributeSet attributes,
                                         final MasterReport report)
  {
    final PrintRequestAttributeSet reportAttributes =
        copyConfiguration(null, report);
    // now, compare that minimal set with the given attribute collection.

    final Attribute[] printAttribs = reportAttributes.toArray();
    boolean invalidConfig = false;
    for (int i = 0; i < printAttribs.length; i++)
    {
      final Attribute attrib = printAttribs[i];
      if (attributes.containsValue(attrib) == false)
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

        throw new PrintException
            ("The print service implementation does not support the Pageable Flavor.");
      }
    }

    PrintRequestAttributeSet attributes =
        Java14PrintUtil.copyConfiguration(null, report);
    attributes = Java14PrintUtil.copyAuxillaryAttributes(attributes, report);

    final PrintReportProcessor reportPane = new PrintReportProcessor(report);
    final DocPrintJob job = printService.createPrintJob();
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

    if (services.length == 0)
    {
      throw new PrintException
          ("Unable to find a matching print service implementation.");
    }
    PrintRequestAttributeSet attributes =
        Java14PrintUtil.copyConfiguration(null, report);
    attributes = Java14PrintUtil.copyAuxillaryAttributes(attributes, report);

    final PrintService service = ServiceUI.printDialog
        (null, 50, 50, services, lookupPrintService(),
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

              return Printable.PAGE_EXISTS;
            }
          }
        }, flavor, null);
        DocPrintJob job = service.createPrintJob();
        PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
        job.print(doc, attributes);
        out.close();
      }
    } else {
      // parrt: works with [image/jpeg, image/png, image/x-png, image/vnd.wap.wbmp, image/bmp, image/gif]
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

        }
    }

    int[] convertAttributes(PrintRequestAttributeSet attrs, DocFlavor flavor)
            throws PrintException {
        PrintRequestAttributeSet attributes = null;
        if (attrs == null ||
            flavor.equals(DocFlavor.INPUT_STREAM.AUTOSENSE) ||
            flavor.equals(DocFlavor.BYTE_ARRAY.AUTOSENSE) ||
            flavor.equals(DocFlavor.URL.AUTOSENSE)) {
            int[] defaultValues = {-1, -1, -1, -1, -1, -1, -1, -1};
            return defaultValues;
        } else {
            attributes = attrs;
        }
        Attribute[] requestAttrs = attributes.toArray();
        int[] printAttributes = new int[ATTRIBUTES_ARRAY_SIZE];
        Arrays.fill(printAttributes, -1);
        for (int i = 0; i < requestAttrs.length; i++) {
            Class category = requestAttrs[i].getCategory();
            if (!isAttributeValueSupported(requestAttrs[i], flavor, attrs)) {
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

        }
        */

        DocFlavor docFlavor = DocFlavor.BYTE_ARRAY.PDF;
        Doc myDoc = new SimpleDoc(out.toByteArray(), docFlavor, null);
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(new Copies(1));
        //aset.add(MediaSize.A4);
        aset.add(Sides.ONE_SIDED);

        PrintService[] services = PrintServiceLookup.lookupPrintServices(docFlavor, aset);
        if (services.length > 0) {
            DocPrintJob job = services[0].createPrintJob();
            try {
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

   * no printers were found or an error occurred.
   */
  public static String[] listPrinters(){
    String[] printerNames = new String[0];
    try {
      PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
      DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
      PrintService printService[] =  PrintServiceLookup.lookupPrintServices(flavor, pras);
      printerNames = new String[printService.length];
      for(int i=0;i<printService.length;i++){
        String name = "Error";
View Full Code Here

Examples of javax.print.attribute.PrintRequestAttributeSet

      String[] pINs, String[] pUKs, String hardTokenSerialPrefix,
      String hardTokenSN, String copyOfHardTokenSN) throws PrinterException{
    if(currentService == null
       || currentPrinterName == null
       || !printerName.equals(currentPrinterName)){
      PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
      DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
      PrintService printService[] =  PrintServiceLookup.lookupPrintServices(flavor, pras);
      int i = 0;
      String trimemdPrinterName = printerName.trim();
      while ( i<printService.length && !trimemdPrinterName.equalsIgnoreCase(printService[i].getName()) ){
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.