FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   printing in p5
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: printing in p5  (Read 2124 times)
pinkwalker

WWW Email
printing in p5
« on: May 26th, 2004, 5:09am »

I'm working in an applet and i need to print the images as seen in the screen. Has any one idea?
 
Gabriel
 

***************
www.pinkwalker.tk
amoeba

WWW
Re: printing in p5
« Reply #1 on: May 26th, 2004, 9:34am »

Hi Gabriel,
 
Try using Toxi's BAppLauncher hack (see Toxi's post further down on the page). You'll need a Java run-time (available from www.java.com).
 
BAppLauncher allows you to run your applet in an application context, which means you can use saveFrame() as usual.
« Last Edit: May 26th, 2004, 9:35am by amoeba »  

marius watz // amoeba
http://processing.unlekker.net/
pinkwalker

WWW Email
Re: printing in p5
« Reply #2 on: Oct 20th, 2004, 7:45am »

hi,
 
i try with the java printing mode (http://java.sun.com/docs/books/tutorial/2d/printing/), but i can't make it work.
 
Gabriel
 

***************
www.pinkwalker.tk
forkinsocket

forkinsockt WWW
Re: printing in p5
« Reply #3 on: Nov 21st, 2004, 11:10am »

hi pinkwalker,
 
i had to do this recently. there is some great sample code in a book called "java cookbook" published by oreilly press that i found helpful; i repeat it here for your benefit. this is known to work in processing 67 on os x.  
 
to print, call the method printscreendavid().
 
void printscreendavid()
{
  // java 1.1 version -- this totally works but brings up an os print dialog. i'm not so fond of those.
  /*
  // fetch printjob object from toolkit
  PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob(new Frame(), "test", null);
 
  // fetch graphics object to draw on (this is what printer sees).
  Graphics pg = pj.getGraphics();
 
  // ask window to paint itself on printer's graphics object
  super.paint(pg);
 
  // say byebye and clean up
  pg.dispose();
  pj.end();
  */
 
  // java 1.2 -- can print in background which is nicer
  try {
    java.awt.print.PrinterJob pjob = java.awt.print.PrinterJob.getPrinterJob();
    pjob.setJobName("FingerprintMazeMap -- You are there.");
    pjob.setCopies(1);
    pjob.setPrintable(new java.awt.print.Printable() {
 public int print(Graphics pg, java.awt.print.PageFormat pf, int pageNum) {
   if (pageNum > 0)
   return java.awt.print.Printable.NO_SUCH_PAGE; // end of job
 
   superPaint(pg);
 
   return java.awt.print.Printable.PAGE_EXISTS;
 }
    });
     
    // calling printDialog forces an OS print dialog -- we don't like os dialogs
    //  if (pjob.printDialog() == false)
    //return;
     
    pjob.print();
  } catch (java.awt.print.PrinterException pe) {
 
  }
}
 
void superPaint(Graphics g) {
  super.paint(g);
}
 
amoeba

WWW
Re: printing in p5
« Reply #4 on: Nov 21st, 2004, 5:06pm »

Thanks for the reminder, I need to do the same for my next project. I just found code available online from O'Reilly's "Java Examples in a Nutshell" that does the same thing. Check http://examples.oreilly.com/jenut/PrintScribble.java, there is also lots of other useful code.
 

marius watz // amoeba
http://processing.unlekker.net/
Pages: 1 

« Previous topic | Next topic »