public void printPage(String size)
	    {
	    	double width = 0.0;
            double height = 0.0;
            double margin = 0.0;
            PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
	    	try{
		    PrinterJob pj = PrinterJob.getPrinterJob();
	        if (pj.printDialog()) {
	            PageFormat pf = pj.defaultPage();
	            Paper paper = pf.getPaper();
	            if(size.equals("3r"))
	            {
	            	width = 5d * 72d;
		            height = 3.5d * 72d;
		            margin = 0d * 72d;
		            aset.add(MediaSizeName.JIS_B7);
	            }
	            else if(size.equals("4r"))
	            {
	            	width = 6d * 72d;
		            height = 4d * 72d;
		            margin = 0d * 72d;
		            aset.add(MediaSizeName.JAPANESE_POSTCARD);
	            }
	            else if(size.equals("5r"))
	            {
	            	width = 7d * 72d;
		            height = 5d * 72d;
		            margin = 0d * 72d;
		            aset.add(MediaSizeName.NA_5X7);
	            }
	            else if(size.equals("6r"))
	            {
	            	width = 8d * 72d;
		            height = 6d * 72d;
		            margin = 0d * 72d;
		            aset.add(MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
	            }
	            else if(size.equals("8r"))
	            {
	            	width = 10d * 72d;
		            height = 8d * 72d;
		            margin = 0d * 72d;
		            aset.add(MediaSizeName.NA_8X10);
	            }
	            paper.setSize(width, height);
	            paper.setImageableArea(
	                    margin,
	                    margin,
	                    width - (margin * 2),
	                    height - (margin * 2));
	            System.out.println("Before- " + dump(paper));
	            pf.setOrientation(PageFormat.LANDSCAPE);
	            pf.setPaper(paper);
	            System.out.println("After- " + dump(paper));
	            System.out.println("After- " + dump(pf));
	            dump(pf);
	            PageFormat validatePage = pj.validatePage(pf);
	            System.out.println("Valid- " + dump(validatePage));
	
	            Book pBook = new Book();
	            pBook.append(this, pf);
	            pj.setPageable(pBook);
	            
	           
	            aset.add(OrientationRequested.LANDSCAPE);
	            
	            try {
	                pj.setPrintable(this);
	                pj.print(aset);
	            } catch (PrinterException ex) {
	                ex.printStackTrace();
	            }
	        }
	
	    } catch (Exception exp) {
	        exp.printStackTrace();
	    }
    }