Adding very long teksts without whitespaces to a GridPrint causes this error:
org.eclipse.swt.SWTError: Unspecified errorIterator net.sf.paperclips.GridIterator@b28980 produced a 126770x3785 piece for a 4468x5801 area.
The application is unable to recover from the error and terminates.
Any ideas on how to work around this? If this is a known error, is there a patch available?
I have tried all kinds of works arounds, such as different grid layouts (preferred, default, grow, etc) and wrapping the grid in BigPrint (which actually removes the SWTError, but causes the text to be printed over many pages, each page only containing about two lines worth of text, centered at the middle of the page.)
Thanks in advance for any help on this issue.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The first thing I'd suggest is to check out the latest PaperClips sources into your workspace from SVN and see if that fixes the problem. If so then I should build a new release. If not, please send me a standalone snippet that demonstrates the problem so I can debug it and see what's going on
This error is meant to catch custom print classes misbehaving, so imagine my surprise to find out that GridPrint is the culprit!
Matthew
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please make this easy on me and submit a standalone snippet that I can just drop in my workspace and run. I'd like to help you and get this fixed, but I don't have hours to spare hunting this down.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following snippet makes Paperclips bork with the exception explained above. If you change the loop to i < 10, then it works. Or you can add spaces in the string to make it work as well.
public class PaperclipsTest
{
public static void main(String[] args)
{
DefaultGridLook look = new DefaultGridLook();
look.setCellSpacing(7, 2);
GridPrint testGrid = new GridPrint("l:p:n, d:g", look);
StringBuffer str = new StringBuffer();
for(int i=0; i < 100; i++)
str.append("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
testGrid.add(new TextPrint(str.toString()));
PagePrint page = new PagePrint(testGrid);
PrintJob printJob = new PrintJob("Test", page).setMargins(38);
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Test GUI");
shell.setSize(500, 500);
PrintPreview preview = new PrintPreview(shell, SWT.NULL);
preview.setPrintJob(printJob);
preview.setSize(500,500);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
I found the problem. GridPrint was miscalculating column widths due to an integer overflow. I've committed a fix to SVN that should fix the problem. Please update your workspace with the latest sources and tell me if this fixes things on your side.
Matthew
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Adding very long teksts without whitespaces to a GridPrint causes this error:
org.eclipse.swt.SWTError: Unspecified errorIterator net.sf.paperclips.GridIterator@b28980 produced a 126770x3785 piece for a 4468x5801 area.
The application is unable to recover from the error and terminates.
Any ideas on how to work around this? If this is a known error, is there a patch available?
I have tried all kinds of works arounds, such as different grid layouts (preferred, default, grow, etc) and wrapping the grid in BigPrint (which actually removes the SWTError, but causes the text to be printed over many pages, each page only containing about two lines worth of text, centered at the middle of the page.)
Thanks in advance for any help on this issue.
The first thing I'd suggest is to check out the latest PaperClips sources into your workspace from SVN and see if that fixes the problem. If so then I should build a new release. If not, please send me a standalone snippet that demonstrates the problem so I can debug it and see what's going on
This error is meant to catch custom print classes misbehaving, so imagine my surprise to find out that GridPrint is the culprit!
Matthew
Easy enough to reproduce - just add a long text without whitespaces to a grid and BOOM.
Please make this easy on me and submit a standalone snippet that I can just drop in my workspace and run. I'd like to help you and get this fixed, but I don't have hours to spare hunting this down.
Matthew,
The following snippet makes Paperclips bork with the exception explained above. If you change the loop to i < 10, then it works. Or you can add spaces in the string to make it work as well.
Hope this helps diagnose the problem.
------------------------------SNIPPET--------------------------------
import net.sf.paperclips.*;
import net.sf.paperclips.ui.PrintPreview;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class PaperclipsTest
{
public static void main(String[] args)
{
DefaultGridLook look = new DefaultGridLook();
look.setCellSpacing(7, 2);
GridPrint testGrid = new GridPrint("l:p:n, d:g", look);
StringBuffer str = new StringBuffer();
for(int i=0; i < 100; i++)
str.append("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
testGrid.add(new TextPrint(str.toString()));
PagePrint page = new PagePrint(testGrid);
PrintJob printJob = new PrintJob("Test", page).setMargins(38);
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Test GUI");
shell.setSize(500, 500);
PrintPreview preview = new PrintPreview(shell, SWT.NULL);
preview.setPrintJob(printJob);
preview.setSize(500,500);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
------------------------------SNIPPET--------------------------------
Anonymous,
I found the problem. GridPrint was miscalculating column widths due to an integer overflow. I've committed a fix to SVN that should fix the problem. Please update your workspace with the latest sources and tell me if this fixes things on your side.
Matthew
Thanks for fixing this so fast!
Could you upload a new redistributable as well?
I'll see if I can get that done tonight