Package javax.print

Examples of javax.print.PrintService


       
        return printRequestAttributeSet;
    }
   
    private PrintService assignPrintService() throws PrintException {
        PrintService printService;
       
        if ((config.getHostname().equalsIgnoreCase("localhost"))
            && (config.getPrintername().equalsIgnoreCase("default"))) {
            printService = PrintServiceLookup.lookupDefaultPrintService();           
        } else {
View Full Code Here


    private DocPrintJob assignPrintJob(PrintService printService) {
        return printService.createPrintJob();
    }
   
    private PrintService assignPrintService() throws PrintException {
        PrintService printService;
       
        if ((config.getHostname().equalsIgnoreCase("localhost"))
            && (config.getPrintername().equalsIgnoreCase("/default"))) {
            printService = PrintServiceLookup.lookupDefaultPrintService();           
        } else {
View Full Code Here

        }

        int numberOfPrintservicesBefore = PrintServiceLookup.lookupPrintServices(null, null).length;

        // setup javax.print
        PrintService ps1 = mock(PrintService.class);
        when(ps1.getName()).thenReturn("printer1");
        when(ps1.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
        PrintService ps2 = mock(PrintService.class);
        when(ps2.getName()).thenReturn("printer2");
        boolean res1 = PrintServiceLookup.registerService(ps1);
        assertTrue("PrintService #1 should be registered.", res1);
        boolean res2 = PrintServiceLookup.registerService(ps2);
        assertTrue("PrintService #2 should be registered.", res2);
        PrintService[] pss = PrintServiceLookup.lookupPrintServices(null, null);
View Full Code Here

    public void printerNameTest() throws Exception {
        if (isAwtHeadless()) {
            return;
        }
        // setup javax.print
        PrintService ps1 = mock(PrintService.class);
        when(ps1.getName()).thenReturn("MyPrinter\\\\remote\\printer1");
        when(ps1.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
        boolean res1 = PrintServiceLookup.registerService(ps1);
        assertTrue("The Remote PrintService #1 should be registered.", res1);
        DocPrintJob job1 = mock(DocPrintJob.class);
        when(ps1.createPrintJob()).thenReturn(job1);

        context.addRoutes(new RouteBuilder() {

            public void configure() {
                from("direct:start1").to("lpr://remote/printer1?sendToPrinter=true");
View Full Code Here

        assertEquals("reverse-landscape", attribute.toString());
    }

    protected void setupJavaPrint() {
        // "install" another default printer
        PrintService psDefault = mock(PrintService.class);
        when(psDefault.getName()).thenReturn("DefaultPrinter");
        when(psDefault.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
        PrintServiceLookup psLookup = mock(PrintServiceLookup.class);
        when(psLookup.getPrintServices()).thenReturn(new PrintService[]{psDefault});
        when(psLookup.getDefaultPrintService()).thenReturn(psDefault);
        DocPrintJob docPrintJob = mock(DocPrintJob.class);
        when(psDefault.createPrintJob()).thenReturn(docPrintJob);
        MediaTray[] trays = new MediaTray[]{
            MediaTray.TOP,
            MediaTray.MIDDLE,
            MediaTray.BOTTOM
        };
        when(psDefault.getSupportedAttributeValues(Media.class, null, null)).thenReturn(trays);
        PrintServiceLookup.registerServiceProvider(psLookup);
    }
View Full Code Here

            return null;
        }
    }
   
    private PrintService assignPrintService() throws PrintException {
        PrintService printService;
       
        if ((config.getHostname().equalsIgnoreCase("localhost"))
            && (config.getPrintername().equalsIgnoreCase("default"))) {
            printService = PrintServiceLookup.lookupDefaultPrintService();           
        } else {
View Full Code Here

     * Tests that if this attribute set does not support the add() operation
     * UnmodifiableSetException is thrown.
     */
    public final void testAdd2() {

        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        if (service != null) {
            PrintServiceAttributeSet psaset = service.getAttributes();
            try{
                psaset.add(ColorSupported.NOT_SUPPORTED);
                fail("add() doesn't throw Exception when" +
                    "trying to add attribute to unmodifiable attribute set ");
            } catch (UnmodifiableSetException e){
View Full Code Here

     * equals(Object object) method testing.
     */
    public final void testEquals() {

        aset = new HashAttributeSet();
        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        if (service != null) {
            PrintServiceAttributeSet psaset = service.getAttributes();
            if (aset.addAll(psaset)){
                assertTrue(aset.equals(psaset));
            }
        } else {
            System.out.println("Warning: default print service wasn't found!\n"
View Full Code Here

    if ( jobName instanceof String ) {
      report.getReportConfiguration().setConfigProperty( PrintUtil.PRINTER_JOB_NAME_KEY, String.valueOf( jobName ) );
    }

    final PrintService printer = findPrintService( printerName );
    try {
      Java14PrintUtil.printDirectly( report, printer );
    } catch ( PrintException e ) {
      return false;
    } catch ( ReportProcessingException e ) {
View Full Code Here

            // restore any the printer attributes from a previous session, if needed
            _restorePrinterAttr();

            if (_printerJob.printDialog(_printerAttr)) {
                // remember the printer name
                PrintService ps = _printerJob.getPrintService();
                if (ps == null)
                    return;
                Preferences.set(prefKey, ps.getName());

                // save the printer attributes for future sessions
                _savePrinterAttr();

                // print the table (this will call the print method below)
View Full Code Here

TOP

Related Classes of javax.print.PrintService

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.