Printing diagrammer view at current zoom level

Article ID: 2388
Last updated: 29 May, 2018
Article ID: 2388
Last updated: 29 May, 2018
Revision: 3
Views: 539
Posted: 08 Mar, 2011
by Dean J.
Updated: 29 May, 2018
by Gargani A.

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();

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2388
Last updated: 29 May, 2018
Revision: 3
Views: 539
Posted: 08 Mar, 2011 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category