Example usage for javax.print.attribute.standard OrientationRequested PORTRAIT

List of usage examples for javax.print.attribute.standard OrientationRequested PORTRAIT

Introduction

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

Prototype

OrientationRequested PORTRAIT

To view the source code for javax.print.attribute.standard OrientationRequested PORTRAIT.

Click Source Link

Document

The content will be imaged across the short edge of the medium.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Set up the attribute set
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(OrientationRequested.PORTRAIT);
    // aset.add(OrientationRequested.LANDSCAPE);

}

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:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java

/**
 * @param actionableTree//from   w  w  w .ja va 2s  .c om
 */
public void print(final JTree actionableTree) {
    /*if (true)
    {
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(OrientationRequested.LANDSCAPE);
    aset.add(new Copies(2));
    aset.add(new JobName("My job", null));
            
    // Create a print job 
    PrinterJob pj = PrinterJob.getPrinterJob();       
    pj.setPrintable(this);
    // locate a print service that can handle the request 
    PrintService[] services =
        PrinterJob.lookupPrintServices();
            
    if (services.length > 0) {
        System.out.println("selected printer " + services[0].getName());
        try {
            pj.setPrintService(services[0]);
            pj.pageDialog(aset);
            if(pj.printDialog(aset)) {
                pj.print(aset);
            }
        } catch (PrinterException pe) { 
            System.err.println(pe);
        }
    }
    return;
    }*/

    DefaultMutableTreeNode clonedTree = GhostActionableTree
            .makeDeepCopy((DefaultMutableTreeNode) actionableTree.getModel().getRoot());
    GhostActionableTree printTree = new GhostActionableTree(this, new DefaultTreeModel(clonedTree));
    printTree.setRowHeight(ROW_HEIGHT);
    //printTree.setEditable(false);
    //printTree.setVisibleRowCount(15);
    ContainerTreeRenderer renderer = new ContainerTreeRenderer(null, false, false);
    renderer.setBGColor(Color.WHITE);
    renderer.setFont(getFont().deriveFont(8.0f));
    //renderer.setLeafIcon(IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std32));
    //renderer.setVerticalTextPosition(SwingConstants.CENTER);
    printTree.setCellRenderer(renderer);

    for (int row = 0; row < printTree.getRowCount(); row++) {
        printTree.expandRow(row);
    }

    PrintablePanel p = new PrintablePanel(new BorderLayout(), printTree);
    p.add(printTree, BorderLayout.CENTER);

    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    //PrinterResolution        pr   = new PrinterResolution(300, 300, PrinterResolution.DPI);
    //MediaPrintableArea       mpa  = new MediaPrintableArea(8,21, 210-16, 296-42, MediaPrintableArea.MM);

    //aset.add( MediaSizeName.IS);
    //aset.add( pr );
    //aset.add( mpa );
    aset.add(new Copies(1));
    aset.add(OrientationRequested.PORTRAIT);
    aset.add(PrintQuality.HIGH);

    PrinterJob job = PrinterJob.getPrinterJob();
    /*PageFormat pageFormat = job.defaultPage();
    Paper      paper      = pageFormat.getPaper();
    paper.setSize(pageFormat.getWidth(), pageFormat.getHeight());
    paper.setImageableArea(
    0,
    0,
    pageFormat.getWidth(),
    pageFormat.getHeight()
    );
    //aset.add( Fidelity.FIDELITY_TRUE );
    pageFormat.setPaper(paper);
            
    Book book = new Book();
    book.append(p, pageFormat, 1);
    job.setPageable(book);*/

    job.setPrintable(p);
    boolean ok = job.printDialog();
    if (ok) {
        try {
            job.print(aset);

        } catch (PrinterException ex) {
            ex.printStackTrace();
            /* The job did not successfully complete */
        }
    }
}

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

public static PageFormat extractPageFormat(final PrintRequestAttributeSet attributeSet) {
    final Media media = (Media) attributeSet.get(Media.class);
    final MediaPrintableArea printableArea = (MediaPrintableArea) attributeSet.get(MediaPrintableArea.class);
    final OrientationRequested orientationRequested = (OrientationRequested) attributeSet
            .get(OrientationRequested.class);

    final MediaSize mediaSize = lookupMediaSize(media);
    if (mediaSize == null) {
        logger.warn("Unknown media encountered, unable to compute page sizes.");
    }/*from   ww  w  .j  a  va2s .  c  o  m*/

    final PageFormat pageFormat = new PageFormat();
    pageFormat.setPaper(createPaper(mediaSize, printableArea));
    if (OrientationRequested.PORTRAIT.equals(orientationRequested)) {
        pageFormat.setOrientation(PageFormat.PORTRAIT);
    } else if (OrientationRequested.LANDSCAPE.equals(orientationRequested)) {
        pageFormat.setOrientation(PageFormat.LANDSCAPE);
    } else if (OrientationRequested.REVERSE_LANDSCAPE.equals(orientationRequested)) {
        pageFormat.setOrientation(PageFormat.REVERSE_LANDSCAPE);
    } else if (OrientationRequested.REVERSE_PORTRAIT.equals(orientationRequested)) {
        pageFormat.setOrientation(PageFormat.PORTRAIT);
    }
    return pageFormat;
}

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

private static OrientationRequested mapOrientation(final int orientation) {
    switch (orientation) {
    case PageFormat.LANDSCAPE:
        return OrientationRequested.LANDSCAPE;
    case PageFormat.REVERSE_LANDSCAPE:
        return OrientationRequested.REVERSE_LANDSCAPE;
    case PageFormat.PORTRAIT:
        return OrientationRequested.PORTRAIT;
    default:/*w  ww  .j  a  v  a 2 s . c  om*/
        throw new IllegalArgumentException("The given value is no valid PageFormat orientation.");
    }
}