Package javax.print.attribute

Examples of javax.print.attribute.PrintRequestAttributeSet


        //On my cheap tesco printer this return null, so accounted for that case.
//        if(area != null) {
//            imagable = area.getPrintableArea(Size2DSyntax.INCH);
//        }
//        else {
          PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
          attributes.add(mediaSizeName);
          MediaPrintableArea areas[] = (MediaPrintableArea[]) printingDevice.getSupportedAttributeValues(MediaPrintableArea.class, null, attributes);
         
          if(testFlag && areas==null)
          System.out.println("Printable Area array is null");
         
View Full Code Here


        {

          exporter = new JRPrintServiceExporter();
          exporter.setExporterInput(new SimpleExporterInput(jasperPrint));

          PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
          printRequestAttributeSet.add(new Copies(mod.getPrintCopies()));


          PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
          printServiceAttributeSet.add(new PrinterName(JPrint.getPrinterServicebyName(printQueue).getName(), Locale.getDefault()));
View Full Code Here

          serviceAttributeSet = new HashPrintServiceAttributeSet();
          serviceAttributeSet.add(new PrinterName(JPrint.getPrinterShortName(JPrint.getPreferredPrinterQueueName()), null));
          exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);
          exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
          exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, mod.isPrintDialog());
          PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
          printRequestAttributeSet.add(new Copies(mod.getPrintCopies()));
          exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
          exporter.exportReport();
         
          /* Alternative method
            exporter = new JRPrintServiceExporter();
View Full Code Here

    log.info(m_info.toString());
    if (m_layout == null)
      layout();
   
    //  Paper Attributes:   media-printable-area, orientation-requested, media
    PrintRequestAttributeSet prats = m_layout.getPaper().getPrintRequestAttributeSet();
    //  add:        copies, job-name, priority
    if (m_info.isDocumentCopy() || m_info.getCopies() < 1)
      prats.add (new Copies(1));
    else
      prats.add (new Copies(m_info.getCopies()));
    Locale locale = Language.getLoginLanguage().getLocale();
    prats.add(new JobName(m_printFormat.getName(), locale));
    prats.add(PrintUtil.getJobPriority(m_layout.getNumberOfPages(), m_info.getCopies(), true));

    try
    {
      //  PrinterJob
      PrinterJob job = getPrinterJob(m_info.getPrinterName());
    //  job.getPrintService().addPrintServiceAttributeListener(this);
      job.setPageable(m_layout.getPageable(false))//  no copy
    //  Dialog
      try
      {
        if (m_info.isWithDialog() && !job.printDialog(prats))
          return;
      }
      catch (Exception e)
      {
        log.log(Level.WARNING, "Operating System Print Issue, check & try again", e);
        return;
      }

    //  submit
      boolean printCopy = m_info.isDocumentCopy() && m_info.getCopies() > 1;
      ArchiveEngine.get().archive(m_layout, m_info);
      PrintUtil.print(job, prats, false, printCopy);

      //  Document: Print Copies
      if (printCopy)
      {
        log.info("Copy " + (m_info.getCopies()-1));
        prats.add(new Copies(m_info.getCopies()-1));
        job = getPrinterJob(m_info.getPrinterName());
      //  job.getPrintService().addPrintServiceAttributeListener(this);
        job.setPageable (m_layout.getPageable(true));    //  Copy
        PrintUtil.print(job, prats, false, false);
      }
View Full Code Here

      DocAttributeSet das = new HashDocAttributeSet();

      try
      {
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        FileInputStream fis = new FileInputStream(filename);
        v_doc = new SimpleDoc(fis, v_flavor, das);
        v_job.print(v_doc, pras);
        logger.debug("Submitting file to spooler : " + filename);
View Full Code Here

    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

    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

                                       DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                       attributes, (Frame)null);
        pageDialog.show();

        if (pageDialog.getStatus() == ServiceDialog.APPROVE) {
            PrintRequestAttributeSet newas =
                pageDialog.getAttributes();
            Class amCategory = SunAlternateMedia.class;

            if (attributes.containsKey(amCategory) &&
                !newas.containsKey(amCategory)) {
                attributes.remove(amCategory);
            }
            attributes.addAll(newas);

            PageFormat page = defaultPage();
View Full Code Here

        if (GraphicsEnvironment.isHeadless()) {
            throw new HeadlessException();
        }

        PrintRequestAttributeSet attributes =
          new HashPrintRequestAttributeSet();
        attributes.add(new Copies(getCopies()));
        attributes.add(new JobName(getJobName(), null));
        boolean doPrint = printDialog(attributes);
        if (doPrint) {
            JobName jobName = (JobName)attributes.get(JobName.class);
            if (jobName != null) {
                setJobName(jobName.getValue());
            }
            Copies copies = (Copies)attributes.get(Copies.class);
            if (copies != null) {
                setCopies(copies.getValue());
            }

            Destination dest = (Destination)attributes.get(Destination.class);

            if (dest != null) {
                try {
                    mDestType = RasterPrinterJob.FILE;
                    mDestination = (new File(dest.getURI())).getPath();
View Full Code Here

        SecurityManager security = System.getSecurityManager();
        if (security != null) {
          security.checkPrintJobAccess();
        }
        PrintRequestAttributeSet requestSet = null;
        PrintServiceAttributeSet serviceSet = null;

        if (attributes != null && !attributes.isEmpty()) {

            requestSet = new HashPrintRequestAttributeSet();
            serviceSet = new HashPrintServiceAttributeSet();

            Attribute[] attrs = attributes.toArray();
            for (int i=0; i<attrs.length; i++) {
                if (attrs[i] instanceof PrintRequestAttribute) {
                    requestSet.add(attrs[i]);
                } else if (attrs[i] instanceof PrintServiceAttribute) {
                    serviceSet.add(attrs[i]);
                }
            }
        }
View Full Code Here

TOP

Related Classes of javax.print.attribute.PrintRequestAttributeSet

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.