Package javax.print

Examples of javax.print.DocFlavor


   */
  public static PrintService[] lookupPrintServices()
  {
    return PrintServiceLookup.lookupPrintServices
      (
       new DocFlavor("application/x-java-jvm-local-objectref",
         "java.awt.print.Pageable"),
       null);
  }
View Full Code Here


   * @throws PrintException
   */
  public final void doPrint() throws IOException, PrintException {

    System.out.println("Printing ");
    DocFlavor flavor = DocFlavor.CHAR_ARRAY.TEXT_PLAIN;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    //aset.add(MediaSizeName.NA_LETTER);
    PrintService[] pservices = PrintServiceLookup.lookupPrintServices(
        flavor, aset);
    int i;
View Full Code Here

    // the maximum file size for printing in KB
    int maxFileSize = 50;

    public PrintManager(String workingDirectory) {
        DocFlavor format = DocFlavor.INPUT_STREAM.AUTOSENSE;
        services = PrintServiceLookup.lookupPrintServices(format, null);
        printerPropsFile = new File(workingDirectory, PRINTER_ASSIGNMENT_FILE);
        locationPropsFile = new File(workingDirectory, LOCATION_FILE);
    }
View Full Code Here

    private void doPrint(PrintService service, File toPrintFile) throws Exception {
        FileInputStream stream = null;
        try {
            stream = new FileInputStream(toPrintFile);
            DocFlavor format = DocFlavor.INPUT_STREAM.AUTOSENSE;
            Doc myDoc = new SimpleDoc(stream, format, null);
            PrintRequestAttributeSet aset = null;
            // new HashPrintRequestAttributeSet();
            // aset.add(new Copies(1));
            // aset.add(MediaSize.ISO.A4);
View Full Code Here

   
    // the maximum file size for printing in KB
    int maxFileSize = 50;
   
    public PrintManager(String workingDirectory) {
        DocFlavor format = DocFlavor.INPUT_STREAM.AUTOSENSE;
        services = PrintServiceLookup.lookupPrintServices(format, null);
        printerPropsFile = new File(workingDirectory, PRINTER_ASSIGNMENT_FILE);
    }
View Full Code Here

   
    private void doPrint(PrintService service, File toPrintFile) throws Exception {
        FileInputStream stream = null;
        try {
            stream = new FileInputStream(toPrintFile);
            DocFlavor format = DocFlavor.INPUT_STREAM.AUTOSENSE;
            Doc myDoc = new SimpleDoc(stream, format, null);
            PrintRequestAttributeSet aset = null;
              // new HashPrintRequestAttributeSet();
            // aset.add(new Copies(1));
            // aset.add(MediaSize.ISO.A4);
View Full Code Here

    for (int i = 0; i < printers.length; i++) {
      System.out.println(printers[i].getName());
    }
   
    // Localiza todas as impressoras com suporte a impress�o de PDFs e com suporte a cores
    DocFlavor pdfFlavor = DocFlavor.BYTE_ARRAY.PDF;
   
    AttributeSet attributes = new HashAttributeSet();
    attributes.add(Chromaticity.COLOR);

    PrintService[] pdfPrinters = PrintServiceLookup.lookupPrintServices(pdfFlavor, attributes);
View Full Code Here

      PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
      System.out.println("Impressora: " + printer.getName());
     
      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
View Full Code Here

            throw new PrintException("Printer is not accepting job.");
        }

        this.doc = doc;
        /* check if the parameters are valid before doing much processing */
        DocFlavor flavor = doc.getDocFlavor();
        Object data;

        try{
            data = doc.getPrintData();
        }catch(IOException e){
            notifyEvent(PrintJobEvent.JOB_FAILED);
            throw new PrintException("can't get print data: " + e.toString());
        }

        if(flavor == null || (!service.isDocFlavorSupported(flavor))){
            notifyEvent(PrintJobEvent.JOB_FAILED);
            throw new PrintJobFlavorException("invalid flavor", flavor);
        }

        initializeAttributeSets(doc, attributes);

        getAttributeValues(flavor);

        String repClassName = flavor.getRepresentationClassName();

        if(flavor.equals(DocFlavor.INPUT_STREAM.GIF) || flavor.equals(DocFlavor.INPUT_STREAM.JPEG)
                || flavor.equals(DocFlavor.INPUT_STREAM.PNG) || flavor.equals(DocFlavor.BYTE_ARRAY.GIF)
                || flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) || flavor.equals(DocFlavor.BYTE_ARRAY.PNG)){
            try{
                instream = doc.getStreamForBytes();
                if(instream == null){
                    notifyEvent(PrintJobEvent.JOB_FAILED);
                    throw new PrintException("No stream for data");
                }
                printableJob(new ImagePrinter(instream));
                service.wakeNotifier();
                return;
            }catch(ClassCastException cce){
                notifyEvent(PrintJobEvent.JOB_FAILED);
                throw new PrintException(cce);
            }catch(IOException ioe){
                notifyEvent(PrintJobEvent.JOB_FAILED);
                throw new PrintException(ioe);
            }
        }else if(flavor.equals(DocFlavor.URL.GIF) || flavor.equals(DocFlavor.URL.JPEG)
                || flavor.equals(DocFlavor.URL.PNG)){
            try{
                printableJob(new ImagePrinter((URL)data));
                service.wakeNotifier();
                return;
            }catch(ClassCastException cce){
View Full Code Here

            // We don't want to cache the images that get loaded by the FOP engine
            fopFactory.getImageFactory().clearCaches();

            // Print is sent
            DocFlavor psInFormat = new DocFlavor.INPUT_STREAM(printerContentType);
            InputStream bais = new ByteArrayInputStream(baos.toByteArray());
           
            Doc myDoc = new SimpleDoc(bais, psInFormat, null);
            PrintServiceAttributeSet psaset = new HashPrintServiceAttributeSet();
            if (UtilValidate.isNotEmpty(printerName)) {
View Full Code Here

TOP

Related Classes of javax.print.DocFlavor

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.