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


Java Book.append方法代码示例

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


在下文中一共展示了Book.append方法的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: 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

示例14: printFile

import java.awt.print.Book; //导入方法依赖的package包/类
/**
 * An example method to print a file.
 *
 * @param filename
 *            The path of the PDF file to print.
 * @param setupPaper
 *            true to post a page setup dialog
 * @throws java.io.IOException
 */
public void printFile(String filename, boolean setupPaper) throws IOException {
	FileInputStream fis = null;
	try {
		File file = new File(filename);
		fis = new FileInputStream(file);
		FileChannel fc = fis.getChannel();
		ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
		PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page

		PDFPrintPage pages = new PDFPrintPage(pdfFile);

		// Create Print Job.
		// We set the margins to 0, on the default 8.5 x 11 paper

		PrinterJob pjob = PrinterJob.getPrinterJob();
		PageFormat pfDefault = PrinterJob.getPrinterJob().defaultPage();
		Paper defaultPaper = new Paper();
		defaultPaper.setImageableArea(0, 0, defaultPaper.getWidth(), defaultPaper.getHeight());
		pfDefault.setPaper(defaultPaper);
		if (setupPaper) {
			pfDefault = PrinterJob.getPrinterJob().pageDialog(pfDefault);
		}
		pjob.setJobName(file.getName());
		if (pjob.printDialog()) {
			// validate the page against the chosen printer to correct
			// paper settings and margins
			pfDefault = pjob.validatePage(pfDefault);
			Book book = new Book();

			book.append(pages, pfDefault, pdfFile.getNumPages());
			pjob.setPageable(book);

			try {
				pjob.print();
			} catch (PrinterException exc) {
				logger.log(Level.ERROR, exc);
			}
		}
	} finally {
		if (fis != null) {
			fis.close();
		}
	}
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:54,代码来源:PDFPrintPage.java

示例15: Printer

import java.awt.print.Book; //导入方法依赖的package包/类
/**
  * Constructor: Print prescription
  * <p>
  *  
  */
 public Printer(Physician ph, Rezept rp, String presID, String QRCode) {


   //Create a printerJob object
   PrinterJob printJob = PrinterJob.getPrinterJob();
   //Create printerJob to simulate the required number of pages
   PrinterJob printJobSimulation = PrinterJob.getPrinterJob();
   
   
   //Set the name of the PrinterJob
   printJob.setJobName(presID);
    
   //Define the page format including margins
   PageFormat pf = printJob.defaultPage();  
   Paper paper = new Paper();  
   
   double marginHeight = paper.getHeight()*HMARGINRATIO;   
   double marginWidth = paper.getWidth()*WMARGINRATIO;   
   
   paper.setImageableArea(marginWidth, marginHeight, paper.getWidth() - marginWidth * 2, paper.getHeight()  
       - marginHeight * 2);  
   
   pf.setPaper(paper);  

//Determine the number of pages and the last product of each page based on the strings to be printed
   Book bkSimulation = new Book(); 
   Pagecounter pcounter = new Pagecounter(ph,rp,presID,QRCode);
   bkSimulation.append(pcounter,pf);
          
   printJobSimulation.setPageable(bkSimulation);
 
   //Do the simulation
   try {
   	
	printJobSimulation.print();
	
} catch (PrinterException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
 
   
   //Get the indices (last item per page) from the simulation
   List<Integer> pageIndices = pcounter.getIndices();
    
   //Create a book with the determined number of pages
   Book bk = new Book(); 
   
   //Create now the pages of the book (new instances of PrintPage for each page)
   //Specify, which of the listed products is the first and the last on this page
   
   for(int i = 0; i < pageIndices.size()-1; i = i+1) {    

       bk.append(new Page(ph,rp,presID,QRCode,pageIndices.get(i)+1, pageIndices.get(i+1)),pf);

   }

   //Assign the pages
   printJob.setPageable(bk);  
   
   //Show print dialog and start printing if "yes"
   if (printJob.printDialog()) {
   	
     try {
       
   	  printJob.print();
       
     } catch (Exception PrintException) {
       PrintException.printStackTrace();
     }
   }

 }
 
开发者ID:elexis,项目名称:elexis-3-base,代码行数:79,代码来源:Printer.java


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