Java 8 PrintRequestAttributeSet - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PrintRequestAttributeSet class.

This code example shows how to use the following methods:add
    } 
         
    public void print(Doc doc, String jobName) throws PrintException {
        // we need create a new job for each print  
        DocPrintJob job = getPrintService().createPrintJob();
        PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(printRequestAttributeSet);
        attrs.add(new JobName(jobName, Locale.getDefault()));
        job.print(doc, attrs);
    } 
 
    public PrintService getPrintService() {
        return printService;
    } 
 
    public void setPrintService(PrintService printService) {
        this.printService = printService;
    } 
     
    public DocFlavor getFlavor() {
        return flavor;
6
CodeRank
This code example shows how to use the following methods:get
This code example shows how to use the following methods:add
	 * @throws PrintException  
	 */ 
	public void print(String fileName) throws IOException, PrintException {
		System.out.println("PrintServiceDemo.print(): Printing " + fileName);
		DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
		PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
		//aset.add(MediaSize.NA.LETTER); 
		aset.add(MediaSizeName.NA_LETTER);
		//aset.add(new JobName(INPUT_FILE_NAME, null)); 
		PrintService[] pservices = 
			PrintServiceLookup.lookupPrintServices(flavor, aset);
		int i;
		switch(pservices.length) {
		case 0: 
			System.err.println(0);
			JOptionPane.showMessageDialog(PrintServiceDemo.this,
				"Error: No PrintService Found", "Error",  
				JOptionPane.ERROR_MESSAGE);
			return; 
		case 1: 

4
CodeRank
This code example shows how to use the following methods:add
        //ExId:DocumentPreviewAndPrint_PrintDialog_Creation 
        //ExSummary:Creates the print dialog. 
        PrinterJob pj = PrinterJob.getPrinterJob();
 
        // Initialize the Print Dialog with the number of pages in the document. 
        PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
        attributes.add(new PageRanges(1, doc.getPageCount()));
        //ExEnd 
 
        //ExStart 
        //ExId:DocumentPreviewAndPrint_PrintDialog_Check_Result 
        //ExSummary:Check if the user accepted the print and proceed to preview the document. 
        // Proceed with print preview only if the user accepts the print dialog. 
        if (!pj.printDialog(attributes))
            return; 
        //ExEnd 
 
        //ExStart 
        //ExId:DocumentPreviewAndPrint_AsposeWordsPrintDocument_Creation 
        //ExSummary:Creates a special Aspose.Words implementation of the Java Pageable interface. 

5
CodeRank
This code example shows how to use the following methods:add
This code example shows how to use the following methods:add
4
CodeRank
This code example shows how to use the following methods:add
     * @param landscape if true the PageSet is landscape, otherwise portrait. 
     */ 
    public static PrintRequestAttributeSet makePageSet( boolean landscape )
    { 
        PrintRequestAttributeSet pageSet = null;
        pageSet = new HashPrintRequestAttributeSet();
        if ( landscape ) {
            pageSet.add( OrientationRequested.LANDSCAPE );
        } 
        else { 
            pageSet.add( OrientationRequested.PORTRAIT );
        } 
        pageSet.add( MediaSizeName.ISO_A4 );
        pageSet.add(new JobName( Utilities.getTitle( "printer job" ), null ));
        return pageSet;
    } 
} 
4
CodeRank
This code example shows how to use the following methods:add
	protected void onInit() throws Exception {
 
		if (this.copies != null) {
			//Assert.isTrue(printService.isAttributeValueSupported(this.copies, this.docFlavor, this.printService.getAttributes()), 
			//	"Attribute '" + this.copies.getName() + "' with value '" + this.copies.getValue() + "' is not supported."); 
			this.printRequestAttributeSet.add(this.copies);
		} 
 
		if (this.chromaticity != null) {
			Assert.isTrue(this.printServiceExecutor.getPrintService().isAttributeValueSupported(this.chromaticity, this.docFlavor, this.printServiceExecutor.getPrintService().getAttributes()),
				"Attribute '" + this.chromaticity.getName() + "' with value '" + this.chromaticity.getValue() + "' is not supported.");
			this.printRequestAttributeSet.add(this.chromaticity);
		} 
 
		if (this.mediaSizeName != null) {
			Assert.isTrue(this.printServiceExecutor.getPrintService().isAttributeValueSupported(this.mediaSizeName, null, null),
				"Attribute '" + this.mediaSizeName.getName()
				+ "' with value '" + this.mediaSizeName.getValue() + "' is not supported.");
			this.printRequestAttributeSet.add(this.mediaSizeName);
		} 

4
CodeRank
This code example shows how to use the following methods:get
		return new PDFPrinterJob(); 
	} 
 
	@Override 
	public String getUserName() {
		return ((TextSyntax) attributes.get(RequestingUserName.class))
				.getValue();
	} 
 
	@Override 
	public boolean isCancelled() { 
		return false; 
	} 
 
	@Override 
	public PageFormat pageDialog(PageFormat page) throws HeadlessException {
		// No page dialog is supported. 
		return (PageFormat) page.clone();
	} 
 
3
CodeRank
This code example shows how to use the following methods:add
            //  for the page settings to be verified. 
            boolean pageVerify = false;
            if ( pageSet == null ) {
                //  Make the default landscape A4. 
                pageSet = new HashPrintRequestAttributeSet();
                pageSet.add( OrientationRequested.LANDSCAPE );
                pageSet.add( MediaSizeName.ISO_A4 );
                pageSet.add
                    ( new JobName( Utilities.getTitle("printer job"),null ) );
                pageVerify = true;
            } 
 
            try { 
                pj.setPrintService( services[0] );
                pj.setPrintable( plot );
                if ( pageVerify ) {
                    pj.pageDialog( pageSet );
                } 
                if ( pj.printDialog( pageSet ) ) {
                    pj.print( pageSet );
3
CodeRank
See Code Examples for Java 8 PrintRequestAttributeSet Methods: