Problem printing many images

27 views
Skip to first unread message

CasaDelGato

unread,
Jun 10, 2012, 2:04:28 PM6/10/12
to swt-pap...@googlegroups.com
I'm running into a problem when I try to print a list of images.
The error looks like this:

!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 creates the print job looks like this:

            GridPrint items = new GridPrint("d");

            String bodytext = msg.getTextBody();

            if ((bodytext != null) && (bodytext.length() > 0)) {
                items.add(new TextPrint(msg.getTextBody()));
            }

            String[] attachNames = msg.getAttachmentNames();
            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));
                    }
                }
            }

            result = new PagePrint(header, items, footer);

Any suggestions on what I might be doing wrong?


Matthew Hall

unread,
Jun 10, 2012, 2:32:04 PM6/10/12
to swt-pap...@googlegroups.com

One of your images is too big. Try using the ImagePrint constructor to configure auto scaling.

--
You received this message because you are subscribed to the Google Groups "SWT PaperClips" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swt-paperclips/-/fRJdKNBnmjMJ.
To post to this group, send email to swt-pap...@googlegroups.com.
To unsubscribe from this group, send email to swt-paperclip...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swt-paperclips?hl=en.

CasaDelGato

unread,
Jun 10, 2012, 6:48:57 PM6/10/12
to swt-pap...@googlegroups.com
Ok, got it working.
Turns out the images can't be EXACTLY the page size either.
I ended up reducing the useable page client area to 95% of it's given value, then printing worked for all images.


On Sunday, June 10, 2012 11:32:04 AM UTC-7, Matthew Hall wrote:

One of your images is too big. Try using the ImagePrint constructor to configure auto scaling.

To post to this group, send email to swt-paperclips@googlegroups.com.
To unsubscribe from this group, send email to swt-paperclips+unsubscribe@googlegroups.com.

Matthew Hall

unread,
Sep 18, 2012, 2:51:02 PM9/18/12
to swt-pap...@googlegroups.com
Wrap the ImagePrint in a ScalePrint will automatically size it down to fit exactly in the available space.
Reply all
Reply to author
Forward
0 new messages