简体   繁体   中英

How to set margins in millimeters?

I have jasperDesign object with units mm, and I call method setMargins(myMargin) to change margins! the problem is with units, I want to setup in millimeters.

JasperDesign jasperDesign = JRXmlLoader.load(reportStream);
jasperDesign.setLeftMargin(newLeftMargin);
jasperDesign.setTopMargin(newTopMargin);
jasperDesign.setColumnWidth(newColumWidth);

Then its time to do some calculation

pixels = (mm * dpi) / 25.4;

The dpi (dot per inch) in jasper report is 72 .

public static int getPixels(float mm, int dpi){
    return Math.round((mm*dpi)/25.4f);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM