Example usage for javax.print.attribute.standard MediaPrintableArea MediaPrintableArea

List of usage examples for javax.print.attribute.standard MediaPrintableArea MediaPrintableArea

Introduction

In this page you can find the example usage for javax.print.attribute.standard MediaPrintableArea MediaPrintableArea.

Prototype

public MediaPrintableArea(int x, int y, int w, int h, int units) 

Source Link

Document

Constructs a MediaPrintableArea object from integer values.

Usage

From source file:net.sourceforge.fenixedu.util.report.ReportsUtils.java

static private PrintRequestAttributeSet createPrintRequestAttributeSet(int width, int height) {
    final PrintRequestAttributeSet result = new HashPrintRequestAttributeSet();

    result.add(MediaSizeName.ISO_A4);
    result.add(OrientationRequested.PORTRAIT);
    result.add(new MediaPrintableArea(0, 0, width, height, MediaPrintableArea.MM));

    return result;
}

From source file:org.pentaho.reporting.engine.classic.extensions.modules.java14print.Java14PrintUtil.java

/**
 * This method replaces the media definition from the given attribute set with the one found in the report itself.
 * <p/>//from www  .j  a va  2s.  c  o  m
 * If no JobName is set, a default jobname will be assigned.
 *
 * @param attributes
 * @param report
 * @return
 */
public static PrintRequestAttributeSet copyConfiguration(PrintRequestAttributeSet attributes,
        final MasterReport report) {
    if (attributes == null) {
        attributes = new HashPrintRequestAttributeSet();
    }

    // for now, be lazy, assume that the first page is the reference
    final PageDefinition pdef = report.getPageDefinition();
    final PageFormat format = pdef.getPageFormat(0);
    final Paper paper = format.getPaper();

    final Media media = MediaSize.findMedia((float) (paper.getWidth() / POINTS_PER_INCH),
            (float) (paper.getHeight() / POINTS_PER_INCH), Size2DSyntax.INCH);
    attributes.add(media);

    final MediaPrintableArea printableArea = new MediaPrintableArea(
            (float) (paper.getImageableX() / POINTS_PER_INCH),
            (float) (paper.getImageableY() / POINTS_PER_INCH),
            (float) (paper.getImageableWidth() / POINTS_PER_INCH),
            (float) (paper.getImageableHeight() / POINTS_PER_INCH), Size2DSyntax.INCH);

    attributes.add(printableArea);
    attributes.add(mapOrientation(format.getOrientation()));

    return attributes;
}