| | | | Browse by category |
Question
How do I print the diagrammer view at the current zoom level?
Answer
You can achieve this with the help of the IlvPrintableDocument and IlvPrintingController classes as well as the java.awt.print.Paper class.
For example, the following code snippet creates a 500 x 500 pixel bitmap:
import ilog.views.util.print.*;
import java.awt.print.*;
...
IlvDiagrammer diag = diagrammerView.getDiagrammer();
IlvPrintableDocument doc = diag.getPrintingController().getDocument();
Paper paper = new Paper();
// the next statement defines how many pixels are in the image
paper.setSize(500, 500);
// the next statement defines the margin. In this example, we use no margin
paper.setImageableArea(0, 0, 500, 500);
PageFormat pageFormat = new PageFormat();
pageFormat.setPaper(paper);
pageFormat.setOrientation(PageFormat.PORTRAIT);
doc.setPageFormat(pageFormat);
try{
diag.printToBitmap(new File("dump.jpg"));
}
catch(Exception e) {
e.printStackTrace();
}