Link to home
Start Free TrialLog in
Avatar of fintan
fintan

asked on

Printing multipage TIFFs from an applet.

Hi Folks,

I need to be able to print multipage tiffs from an applet (usning IE6.x and JDK1.4). The code below does work however it takes about 2-3 minutes per page. Some of the tiffs I need to print are 20 pages in size. As you can imagine waiting over an hour for a doc to print isn't going down very well. I've attempted turning off double buffering which stop huge spool files being created, however doesn't speed up the print. I've also disabled postscript printing on the printer (read somewhere that this can cause slow printing) but to no avail.

Any ideas? I need to get the printing speed around the same speed as printing directly from windows?

Document print

      if (name.equals("buttonPrint"))
      {
          //Custom button text
          Object[] options = {"Print All Pages", "Print Selected Page", "Cancel Print"};
                             
          int n = JOptionPane.showOptionDialog(
            null, "Would you like to print all the pages or the selected page?",
            "Print",  JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);
               
          if (n == 0)
          {
            try
            {
              // print all pages
              // Open the file.
             
               viewPanel.setDoubleBuffered(false);
             
             
             
              // Don't need to make second call to the URL to get Image
             
              //Page p = PageGetter.getPage(printURL);
              Page p = annotationViewer.getImageSource();
             
             
              p.load(null);

 
              while (p.getState() != Page.PAGE_STATE_LOADED)
              {
                Thread.sleep(500);
              }

     


              AnnotatedPagePrintable app = new AnnotatedPagePrintable(p, true);
         
              // Create a PrinterJob.
              PrinterJob pj = PrinterJob.getPrinterJob();

              // Set the margins.
              PageFormat pf = pj.defaultPage();
           
              // Now Print the page.
              pj.setPrintable(app, pf);
             
              pj.print();
             
              viewPanel.setDoubleBuffered(true);
             
          }
          catch (Exception ex)
          {
             //  Something went wrong.
            ex.printStackTrace();
          }
        }
        else if (n == 1)
        {
          annotationViewer.printImage();
        }    

      }      

SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fintan
fintan

ASKER


Jezzz.... That's tragic. It's not like the files are big or anything. A single page is less than 60k and the multipage doc is around 500K.

Is converting the image to another format not likely to cause the same problem when I attempt to print?

Using the windows app isn't really a runner. The client went for the browser based app because of the ease of deployment etc. I had thought about a windows based print server on one machine, but the end users are spread out over a few building with about 100 printers...


Cheers,

Fintan
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fintan

ASKER


Cavalmi,

I tried the snowbound stuff, but those guys sure know how to charge for the toolkit. It was gonna cost some where in the region of £6000 - £8000 depending on the configuration and (I think) there was a per seat licensing charge for end users.

I'll have a hunt for a pdf to postscript lib and see if it does the job
Cheers,
Fintan
Avatar of fintan

ASKER

I haven't been able to find a tiff2ps library... but as cavalmi and tim have pointed out it appears to be an issue with the JDK... and I'll probably have to live with it...

Cheers,

Fintan
Hopefully it will be sorted out in 1.5...  I have heard rumours that it is much faster with java2d...not tested it yet though...

Good luck!!