I have a Canvas with a child image in the background and some child Labels in the foreground (differnt ZIndex). The positions of the children are set with setTop(), setLeft(), setWidth() and setHeight(). When I print the Canvas with Canvas.showPrintPreview the print preview and print looks weird (see attachements). The problem occurs in IE, firefox and chrome (I have not tested Safari so far). The developer console says that I am using
version SC_SNAPSHOT-2011-10-03/PowerEdition Deployment (built 2011-10-03)
How can I print the Canvas correctly?
Here is the code
version SC_SNAPSHOT-2011-10-03/PowerEdition Deployment (built 2011-10-03)
How can I print the Canvas correctly?
Here is the code
Code:
public class PrintBug implements EntryPoint { private Canvas m_MainCanvas; /** * This is the entry point method. */ public void onModuleLoad() { int width = 640; int height = 480; m_MainCanvas = new Canvas(); m_MainCanvas.setWidth(width); m_MainCanvas.setHeight(height); int imageWidth = 400; int imageHeight = 300; Img image = new Img("IMG_20111028_133201.jpg"); image.setLeft((width - imageWidth) / 2); image.setTop((height - imageHeight) / 2); image.setWidth(imageWidth); image.setHeight(imageHeight); image.setZIndex(1); m_MainCanvas.addChild(image); for(int x = 0; x < 640; x += 80) { for(int y = 0; y < 480; y += 80) { Label label = new Label(x + "," + y); label.setMargin(1); label.setBorder("1px solid black"); label.setLeft(x); label.setTop(y); label.setWidth(80); label.setHeight(80); label.setZIndex(2); m_MainCanvas.addChild(label); } } HLayout layout = new HLayout(); layout.addMember(createButtons()); layout.addMember(m_MainCanvas); RootPanel.get().add(layout); layout.draw(); } private VLayout createButtons() { Button button = new Button("Print"); button.addClickHandler(new ClickHandler() { @SuppressWarnings("synthetic-access") public void onClick(final ClickEvent event) { Canvas.showPrintPreview(m_MainCanvas); } }); VLayout ret = new VLayout(); ret.setMargin(5); ret.addMember(button); return ret; } }
Comment