当前位置: 首页>>代码示例>>Java>>正文


Java Book类代码示例

本文整理汇总了Java中java.awt.print.Book的典型用法代码示例。如果您正苦于以下问题:Java Book类的具体用法?Java Book怎么用?Java Book使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Book类属于java.awt.print包,在下文中一共展示了Book类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import java.awt.print.Book; //导入依赖的package包/类
/**
 * Constructs a new PrinterJob, allows the user to select which printer to
 * print to, And then prints the node.
 */
public void print() {
    final PrinterJob printJob = PrinterJob.getPrinterJob();
    final PageFormat pageFormat = printJob.defaultPage();
    final Book book = new Book();
    book.append(this, pageFormat);
    printJob.setPageable(book);

    if (printJob.printDialog()) {
        try {
            printJob.print();
        }
        catch (final PrinterException e) {
            throw new RuntimeException("Error Printing", e);
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:PNode.java

示例2: initialize

import java.awt.print.Book; //导入依赖的package包/类
private void initialize(byte[] pdfContent, String jobName,String nomeImpressora) throws IOException, PrinterException {
    ByteBuffer bb = ByteBuffer.wrap(pdfContent);

    PDFFile pdfFile = new PDFFile(bb);
    PDFPrintPage pages = new PDFPrintPage(pdfFile);

    PrintService[] pservices = PrinterJob.lookupPrintServices();

    System.out.println(pservices.length);
    if (pservices.length > 0) {
        for (PrintService ps : pservices) {
            System.out.println("Impressora Encontrada: " + ps.getName());

            if (ps.getName().contains(nomeImpressora)) {
                System.out.println("Impressora Selecionada: " + nomeImpressora);
                impressora = ps;
                break;
            }
        }
    }
    if (impressora != null) {
        pjob = PrinterJob.getPrinterJob();
        pjob.setPrintService(impressora);

        PageFormat pf = PrinterJob.getPrinterJob().defaultPage();

        pjob.setJobName(jobName);
        Book book = new Book();
        book.append(pages, pf, pdfFile.getNumPages());
        pjob.setPageable(book);

      
        Paper paper = new Paper();
        paper.setSize(getWidth, getHeight);
        paper.setImageableArea(margin, (int) margin / 4, getWidth - margin * 2, getHeight - margin * 2);
        //paper.setImageableArea(margin,margin, paper.getWidth()-margin*2,paper.getHeight()-margin*2);
        pf.setOrientation(orientacao);
        pf.setPaper(paper);
    }
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:41,代码来源:PrintPdf.java

示例3: doPrint

import java.awt.print.Book; //导入依赖的package包/类
/**
 * Print the current document.
 */
public void doPrint() {
    PrinterJob pjob = PrinterJob.getPrinterJob();
    pjob.setJobName(docName);
    Book book = new Book();
    PDFPrintPage pages = new PDFPrintPage(curFile);
    book.append(pages, pformat, curFile.getNumPages());

    pjob.setPageable(book);
    if (pjob.printDialog()) {
        new PrintThread(pages, pjob).start();
    }
}
 
开发者ID:proofy,项目名称:willow-browser,代码行数:16,代码来源:PDFViewer.java

示例4: printFile

import java.awt.print.Book; //导入依赖的package包/类
public void printFile() {
    PrinterJob print = PrinterJob.getPrinterJob();
    PageFormat format = print.pageDialog(new PageFormat());
    if (print.printDialog()) {
        Book b = new Book();
        b.append((Printable)this.bufferGraphics, format);
        print.setPageable(b);
        try { print.print(); }
            catch(PrinterException ex) { ex.printStackTrace(); }
    }
}
 
开发者ID:cjd5551,项目名称:Java_Paint,代码行数:12,代码来源:Paint_GUI.java

示例5: actionPerformed

import java.awt.print.Book; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
	
	// Get the print manager
	PrinterJob printJob = PrinterJob.getPrinterJob();
	Book book = new Book();
	int pages = getEditor().getBoardContainerCount();
	for (int i = 0; i < pages; i++) {
		TBoardContainer boardContainer = getEditor().getBoardContainer(i);
		// Clear selection
		boardContainer.getBoard().clearSelection();
		Dimension boardSize = TBoardConstants.getSize(boardContainer.getBoard().getAttributes(null));
		PageFormat page = printJob.defaultPage();
		if (boardSize.getWidth() > boardSize.getHeight())
			page.setOrientation(PageFormat.LANDSCAPE);
		else
			page.setOrientation(PageFormat.PORTRAIT);
		book.append(boardContainer, page);
	}
	// Set the component to print
	printJob.setPageable(book);
	if (printJob.printDialog()) {
		try {
			printJob.print();
		} catch (Exception ex) {
			// If the print fails show an error message
			JOptionPane.showMessageDialog(null,
					TLanguage.getString("TProjectPrintAction.PRINT_ERROR"),
					TLanguage.getString("TProjectPrintAction.ERROR") + "!",
					JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
开发者ID:ProgettoRadis,项目名称:ArasuiteIta,代码行数:33,代码来源:TProjectPrintAction.java

示例6: printPopG

import java.awt.print.Book; //导入依赖的package包/类
public void printPopG() {
	PrinterJob pj = PrinterJob.getPrinterJob(); 
    Book book = new Book();
    PageFormat documentPageFormat = new PageFormat();
    documentPageFormat.setOrientation(PageFormat.LANDSCAPE);
    book.append(new Document(), documentPageFormat);
    pj.setPageable(book);
    if (pj.printDialog()) {
        try {
        	pj.print();
       	} catch (Exception PrintException) {
       		PrintException.printStackTrace();
        }
      }
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:16,代码来源:PopGUserInterface.java

示例7: print

import java.awt.print.Book; //导入依赖的package包/类
public void print() {
	PrinterJob printerJob = PrinterJob.getPrinterJob();
	Book book = new Book();
	book.append(new PrintPage(), pageFormat);
	printerJob.setPageable(book);
	boolean doPrint = printerJob.printDialog();
	if (doPrint) {
		try {
			printerJob.print();
		} catch (PrinterException exception) {
			System.err.println("Printing error: " + exception);
		}
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:15,代码来源:PrintPreviewPanel.java

示例8: print

import java.awt.print.Book; //导入依赖的package包/类
private void print(final PrintPackageRequest request) throws PrinterException
{
	logger.log(Level.FINE, "Printing request {}", request);

	// Create Print Job
	final PrinterJob pjob = PrinterJob.getPrinterJob();
	pjob.setJobName(request.getPrintJobName());

	final PageFormat pf = pjob.defaultPage();
	final Paper paper = pjob.defaultPage().getPaper();
	final MediaSize size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A4);

	paper.setSize(size.getSize(Size2DSyntax.INCH)[0] * 72, size.getSize(Size2DSyntax.INCH)[1] * 72);
	paper.setImageableArea(0, 0, size.getSize(Size2DSyntax.INCH)[0] * 72, size.getSize(Size2DSyntax.INCH)[1] * 72);
	pf.setPaper(paper);

	final Book book = new Book();// java.awt.print.Book
	book.append(request.getPrintable(), pf, request.getNumPages());
	pjob.setPageable(book);

	pjob.setPrintService(request.getPrintService());
	pjob.print(request.getAttributes());

	// task 09618: allow us to configure the client to return an error even if everything went OK, so we can test
	final String alwaysReturnError = Context.getContext().getProperty(Context.CTX_Testing_AlwaysReturnError, Context.DEFAULT_AlwaysReturnError);
	if (Boolean.parseBoolean(alwaysReturnError))
	{
		logger.log(Level.INFO, "{} is true, so we report an error, despite the print was OK", Context.CTX_Testing_AlwaysReturnError);

		final String errorMsg = Context.getContext().getProperty(Context.CTX_Testing_ErrorMessage, Context.DEFAULT_ErrorMessage);
		throw new PrinterException(errorMsg);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:34,代码来源:PrintingEngine.java

示例9: print

import java.awt.print.Book; //导入依赖的package包/类
/**
 * Constructs a new PrinterJob, allows the user to select which printer to
 * print to, And then prints the node.
 * @throws PrinterException if print fails
 */
public void print() throws PrinterException {
    final PrinterJob printJob = PrinterJob.getPrinterJob();
    final PageFormat pageFormat = printJob.defaultPage();
    final Book book = new Book();
    book.append(this, pageFormat);
    printJob.setPageable(book);

    if (printJob.printDialog()) {
        printJob.print();
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:17,代码来源:PNode.java

示例10: createBook

import java.awt.print.Book; //导入依赖的package包/类
/** Méthode qui formatte le contenu de l'éditeur en pages, rangées dans un Book.
 * Cette méthode modifie les variables book et pages.
 **/
public Book createBook() {
    book = new Book();
    pages = decouperEnPages();
    book.append(this, page, pages.size());
    return book;
}
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:10,代码来源:Formatter.java

示例11: doPrint

import java.awt.print.Book; //导入依赖的package包/类
/**
 * Print the current document.
 */
public void doPrint() {
	PrinterJob pjob = PrinterJob.getPrinterJob();
	pjob.setJobName(docName);
	Book book = new Book();
	PDFPrintPage pages = new PDFPrintPage(curFile);
	book.append(pages, pformat, curFile.getNumPages());
	pjob.setPageable(book);
	if (pjob.printDialog()) {
		new PrintThread(pages, pjob).start();
	}
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:15,代码来源:PdfDialog.java

示例12: print

import java.awt.print.Book; //导入依赖的package包/类
/**
 * Print circuit currently being edited, plus any state machines.
 * 
 * @param all True to print the entire circuit, false to print just what's visible.
 */
public void print(boolean all) {

	// get the currently selected editor, return if none
	Editor ed = (Editor)(edits.getSelectedComponent());
	if (ed == null)
		return;

	// set up printer job
	PrinterJob job = PrinterJob.getPrinterJob();
	PageFormat format = job.defaultPage();
	format.setOrientation(PageFormat.LANDSCAPE);
	Book book = new Book();

	// find all unique sub-circuits (and their state machines)
	if (all) {
		ed.getCircuit().addToBook(book,format);
	}
	else {
		book.append(ed.getCircuit(),format);
	}

	// finish up book
	job.setPageable(book);

	// show dialog, and if ok, print
	if (job.printDialog()) {
		try {
			job.print();
		}
		catch (PrinterException ex) {
			System.out.println("printing error: " + ex.getMessage());
		}
	}
}
 
开发者ID:anadon,项目名称:JLS,代码行数:40,代码来源:JLSStart.java

示例13: printPages

import java.awt.print.Book; //导入依赖的package包/类
void printPages() {

			U.startThread(new Thread() {
				@Override
				public void run() {
					try {
						PrinterJob job = PrinterJob.getPrinterJob();
						PageFormat pf = job.pageDialog(job.defaultPage());
						totalPage = getTotalPage(pf);
						if (totalPage <= 0) {
							return;
						}
						dim = new Dimension((int) pf.getImageableWidth(), (int) pf.getImageableHeight());
						Book bk = new Book();
						bk.append(Print.this, pf, totalPage);
						job.setPageable(bk);
						if (job.printDialog()) {
							ui.message("printing...");
							uiComp.repaint();
							job.print();
							ui.message("print ok");
							uiComp.repaint();
						}
					} catch (Exception e) {
						ui.message("err:" + e);
						uiComp.repaint();
						e.printStackTrace();
					}
				}
			});
		}
 
开发者ID:neoedmund,项目名称:neoeedit,代码行数:32,代码来源:U.java

示例14: main

import java.awt.print.Book; //导入依赖的package包/类
public static void main(String args[]) {
    new Book().getNumberOfPages();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:HeadlessBook.java

示例15: printInfo

import java.awt.print.Book; //导入依赖的package包/类
public void printInfo() throws Exception{
//		int height = 225+15*foodInfos.size();
		int height = getHeight();
		
		Book book = new Book();
		//设置成竖打 
	    PageFormat pf = new PageFormat();
	    pf.setOrientation(PageFormat.PORTRAIT);
	    
	    //通过Paper设置页面的空白边距和可打印区域。必须与实际打印纸张大小相符。  
	    
	    Paper p = new Paper();
//	    p.setSize(590, 840);
	    p.setSize(163,height);//纸张大小
	    //A4(595 X 842)设置打印区域,其实0,0应该是72,72,因为A4纸的默认X,Y边距是72
//	    p.setImageableArea(10,10, 590,840);
	    p.setImageableArea(start_x, -20, 163, height + 20);
	    pf.setPaper(p);
	    
	    //把 PageFormat 和 Printable 添加到书中,组成一个页面 
	    book.append(this, pf);
	    
	    //获取打印机服务对象, 默认打印机
	    PrinterJob job = PrinterJob.getPrinterJob();
	    logger.info("#printInfo. jobName: "+job.getJobName()+", userName; "+job.getUserName());
	    logger.info("#printInfo. 打印机名称: "+job.getPrintService().getName());
	    
	    //日志输出打印机的各项属性  
        AttributeSet attrs = job.getPrintService().getAttributes();
        logger.info("****************************************************");
        for (Attribute attr : attrs.toArray()) {
            String attributeName = attr.getName();
            String attributeValue = attrs.get(attr.getClass()).toString();
            logger.info("*"+attributeName + " : " + attributeValue);
        }
        logger.info("****************************************************");
        
	    //设置打印类
	    job.setPageable(book);
	    
        //可以用printDialog显示打印对话框,在用户确认后打印;也可以直接打印 
        /*boolean a=job.printDialog();
        logger.info("#print. a="+a);*/
	    
	    job.print();
	    
	}
 
开发者ID:hanwwh,项目名称:xqres,代码行数:48,代码来源:PrinterInfo.java


注:本文中的java.awt.print.Book类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。