problem printing long list of images

26 views
Skip to first unread message

CasaDelGato

unread,
Jun 10, 2012, 2:01:50 PM6/10/12
to swt-pap...@googlegroups.com
I'm getting this exception when I print a job that has many images in it:

!ENTRY org.eclipse.ui 4 0 2012-06-10 10:57:32.885
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTError: Unspecified errorUnable to layout page 3
    at org.eclipse.swt.SWT.error(SWT.java:4308)
    at net.sf.paperclips.PaperClips.error(PaperClips.java:82)
    at net.sf.paperclips.PaperClips.error(PaperClips.java:70)
    at net.sf.paperclips.PaperClips.getPages(PaperClips.java:422)
    at net.sf.paperclips.PaperClips.print(PaperClips.java:255)
    at net.sf.paperclips.PaperClips.print(PaperClips.java:210)
    at net.sf.paperclips.PaperClips.print(PaperClips.java:186)
    at com.casadelgato.email.util.MessageUtil.print(MessageUtil.java:609)

The code that adds all the images looks like this:

            GridPrint items = new GridPrint("d");


            for (int idx = 0; (idx < attachNames.length); idx++) {

                String fname = stripFileCID(attachNames[idx]);

                if (getFileType(fname) == FileType.IMAGE) {
                    try {
                        byte[] data = mRepo.getMessageAttachment(msg.getID(), fname);
                        logger.debug("file size is {}", data.length);
                        InputStream in = new ByteArrayInputStream(data);
                        ImageLoader loader = new ImageLoader();
                        ImageData[] id = loader.load(in);
                        if (id.length > 0) {
                            items.add(new ImagePrint(id[0]));
                        }

                    } catch (RemoteException ex) {
                        logger.error("Remote Exception", ex);
                    } catch (FileNotFoundException ex) {
                        items.add(new TextPrint("Missing Attachment File: " + fname));
                    }
                }
            }


Matthew Hall

unread,
Sep 18, 2012, 2:50:08 PM9/18/12
to swt-pap...@googlegroups.com
"Unable to layout page" happens when the layout engine cannot satisfy the layout constraints of your document. In this case, you are using ImagePrint(ImageData) constructor which sets a default image DPI of 72x72.

I suggest one or more of the following:
  • Explicitly set the image DPI high enough to fit on a single page
  • Explicitly set the image size small enough to fit on a single page
  • Wrap the ImagePrint in a ScalePrint with auto-scaling enabled
  • Wrap the ImagePrint in a BigPrint to break the large images content across multiple pages.
Regards,

-Matthew
Reply all
Reply to author
Forward
0 new messages