List of usage examples for javax.print.attribute.standard MediaSizeName NA_LETTER
MediaSizeName NA_LETTER
To view the source code for javax.print.attribute.standard MediaSizeName NA_LETTER.
Click Source Link
From source file:Print.java
public static void main(String[] args) throws IOException { // These are values we'll set from the command-line arguments boolean query = false; String printerName = null;// w w w. j av a 2 s . c o m String inputFileName = null; String outputFileName = null; String outputFileType = null; PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); // Loop through the arguments for (int i = 0; i < args.length; i++) { if (args[i].equals("-q")) query = true; // Is this is query? else if (args[i].equals("-p")) // Specific printer name printerName = args[++i]; else if (args[i].equals("-i")) // The file to print inputFileName = args[++i]; else if (args[i].equals("-ps")) { // Print it to this file // Sun's Java 1.4 implementation only supports PostScript // output. Other implementations might offer PDF, for example. outputFileName = args[++i]; outputFileType = "application/postscript"; } // The rest of the arguments represent common printing attributes else if (args[i].equals("-color")) // Request a color printer attributes.add(Chromaticity.COLOR); else if (args[i].equals("-landscape")) // Request landscape mode attributes.add(OrientationRequested.LANDSCAPE); else if (args[i].equals("-letter")) // US Letter-size paper attributes.add(MediaSizeName.NA_LETTER); else if (args[i].equals("-a4")) // European A4 paper attributes.add(MediaSizeName.ISO_A4); else if (args[i].equals("-staple")) // Request stapling attributes.add(Finishings.STAPLE); else if (args[i].equals("-collate")) // Collate multiple copies attributes.add(SheetCollate.COLLATED); else if (args[i].equals("-duplex")) // Request 2-sided attributes.add(Sides.DUPLEX); else if (args[i].equals("-2")) // 2 pages to a sheet attributes.add(new NumberUp(2)); else if (args[i].equals("-copies")) // how many copies attributes.add(new Copies(Integer.parseInt(args[++i]))); else { System.out.println("Unknown argument: " + args[i]); System.exit(1); } } if (query) { // If the -q argument was specified, but no printer was named, // then list all available printers that can support the attributes if (printerName == null) queryServices(attributes); // Otherwise, look for a named printer that can support the // attributes and print its status else queryPrinter(printerName, attributes); } else if (outputFileName != null) // If this is not a query and we have a filename, print to a file printToFile(outputFileName, outputFileType, inputFileName, attributes); else // Otherwise, print to the named printer, or to the default // printer otherwise. print(printerName, inputFileName, attributes); // The main() method ends here, but there may be a printing thread // operating in the background. So the program may not terminate // until printing completes. }
From source file:org.apache.camel.component.printer.PrinterConfiguration.java
private MediaSizeName assignMediaSize(String size) { MediaSizeAssigner mediaSizeAssigner = new MediaSizeAssigner(); MediaSizeName answer;/*from www. j a va2 s . c o m*/ if (size == null) { // default to NA letter if no size configured answer = MediaSizeName.NA_LETTER; } else if (size.toLowerCase().startsWith("iso")) { answer = mediaSizeAssigner.selectMediaSizeNameISO(size); } else if (size.startsWith("jis")) { answer = mediaSizeAssigner.selectMediaSizeNameJIS(size); } else if (size.startsWith("na")) { answer = mediaSizeAssigner.selectMediaSizeNameNA(size); } else { answer = mediaSizeAssigner.selectMediaSizeNameOther(size); } return answer; }
From source file:org.apache.camel.component.printer.PrinterOperations.java
public PrinterOperations() throws PrintException { printService = PrintServiceLookup.lookupDefaultPrintService(); if (printService == null) { throw new PrintException("Printer lookup failure. No default printer set up for this host"); }//from ww w . j ava2 s .c o m job = printService.createPrintJob(); flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(new Copies(1)); printRequestAttributeSet.add(MediaSizeName.NA_LETTER); printRequestAttributeSet.add(Sides.ONE_SIDED); }
From source file:org.pentaho.reporting.engine.classic.extensions.modules.java14print.Java14PrintUtil.java
private static MediaSize lookupMediaSize(final Media media) { if (media instanceof MediaSizeName) { return MediaSize.getMediaSizeForName((MediaSizeName) media); } else if (media instanceof MediaName) { if (media.equals(MediaName.ISO_A4_TRANSPARENT) || media.equals(MediaName.ISO_A4_WHITE)) { return MediaSize.getMediaSizeForName(MediaSizeName.ISO_A4); } else if (media.equals(MediaName.NA_LETTER_TRANSPARENT) || media.equals(MediaName.NA_LETTER_WHITE)) { return MediaSize.getMediaSizeForName(MediaSizeName.NA_LETTER); }/* w w w . j a va 2s . co m*/ } return null; }