static private PageFormat getMinimumMarginPageFormat(PrinterJob printJob) { PageFormat pf0 = printJob.defaultPage(); PageFormat pf1 = (PageFormat) pf0.clone(); Paper p = pf0.getPaper(); p.setImageableArea(0, 0,pf0.getWidth(), pf0.getHeight()); pf1.setPaper(p); PageFormat pf2 = printJob.validatePage(pf1); return pf2; }
private int getPageHeight(final PageFormat format) { return (int) (format.getHeight() * zoom); }
/** * Returns the horizontal border between the page and the control. */ public int getHorizontalPageBorder() { return (int) Math.round(0.5 * pageFormat.getHeight() * pageScale); }
/** * Returns the horizontal border between the page and the control. */ public int getHorizontalPageBorder() { return (int) Math.round(0.5 * pageFormat.getHeight() * pageScale); }
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { // graphics.drawImage(image_,0,0,image_.getWidth(),image_.getHeight(),null); graphics.drawImage(image_,0,0,(int)pageFormat.getWidth(),(int)pageFormat.getHeight(),null); return 0; } }
/** * Returns the (unscaled) preferred size for the current page format (scaled * by pageScale). */ protected Dimension getPreferredSizeForPage() { return new Dimension((int) Math.round(pageFormat.getWidth() * pageScale * horizontalPageCount), (int) Math.round(pageFormat.getHeight() * pageScale * verticalPageCount)); }
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { // graphics.drawImage(image_,0,0,image_.getWidth(),image_.getHeight(),null); graphics.drawImage(image_,0,0,(int)pageFormat.getWidth(),(int)pageFormat.getHeight(),null); return 0; } }
/** * Returns the (unscaled) preferred size for the current page format (scaled * by pageScale). */ protected Dimension getPreferredSizeForPage() { return new Dimension((int) Math.round(pageFormat.getWidth() * pageScale * horizontalPageCount), (int) Math.round(pageFormat.getHeight() * pageScale * verticalPageCount)); }
public int getPageHeight() { return (int) (pageFormat().getHeight()); }
public Dimension getPreferredSize() { return new Dimension( (int) pageFormat.getWidth(), (int) pageFormat.getHeight() ); }
import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.print.PageFormat; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @Aspect public class JRMinoltaAspect { @Before("execution(int net.sf.jasperreports.engine.print.JRPrinterAWT.print(java.awt.Graphics, java.awt.print.PageFormat , int )) && args(g, pf, ..)") public void scalePrint(Graphics g, PageFormat pf){ if(pf.getOrientation() == PageFormat.LANDSCAPE){ g.translate(0, (int)pf.getHeight() / 2 ); } ((Graphics2D)g).scale(0.5, 0.5); } }
public Dimension getPreferredSize() { if ( pageDefinition == null ) { return new Dimension(); } final PageFormat pageFormat = getPageFormat(); return new Dimension( (int) pageFormat.getWidth(), (int) pageFormat.getHeight() ); }
public Preview(final PrintController printController, final Printable view, Dimension size) { this.printController = printController; this.view = view; final PageFormat format = getPageFormat(); this.zoom = Math.min(size.getHeight() / format.getHeight(), size.getWidth() / format.getWidth()); resize(); }
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if(pageIndex!=0) { return NO_SUCH_PAGE; } Graphics2D g2d = (Graphics2D) graphics; AffineTransform at = new AffineTransform(); at.translate(0, 0); //We need to scale the image properly so that it fits on one page. double xScale = pageFormat.getWidth() / image.getWidth(); double yScale = pageFormat.getHeight() / image.getHeight(); // Maintain the aspect ratio by taking the min of those 2 factors and using it to scale both dimensions. double aspectScale = Math.min(xScale, yScale); at.setToScale(aspectScale, aspectScale); g2d.drawRenderedImage(image, at); return Printable.PAGE_EXISTS; }
final PrinterJob printJob = PrinterJob.getPrinterJob(); printJob.setPrintService(ps); final PageFormat pf = printJob.defaultPage(); System.out.println("Printer Page width=" + pf.getWidth() + " height=" + pf.getHeight());
public static void printPageFormat(PageFormat pf) { System.out.println("paper size:" + pf.getWidth() + "x" + pf.getHeight() + " orientation:" + pf.getOrientation()); System.out.println("imageable position: X=" + pf.getImageableX() + " Y=" + pf.getImageableY()); System.out.println("imageable size:" + pf.getImageableWidth() + "x" + pf.getImageableHeight()); }
@Override public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { DrawVisitorGraphics drawVisitorGraphics = new DrawVisitorGraphics(world, (int) (pageFormat.getWidth()), (int) (pageFormat.getHeight())); drawVisitorGraphics.setGraphics(graphics); drawing.draw(drawVisitorGraphics); return (pageIndex == 0) ? Printable.PAGE_EXISTS : Printable.NO_SUCH_PAGE; }
public Insets getPageMargins( final PageFormat format ) { final int marginLeft = (int) format.getImageableX(); final int marginRight = (int) ( format.getWidth() - format.getImageableWidth() - format.getImageableX() ); final int marginTop = (int) ( format.getImageableY() ); final int marginBottom = (int) ( format.getHeight() - format.getImageableHeight() - format.getImageableY() ); return new Insets( marginTop, marginLeft, marginBottom, marginRight ); }
public DefaultPrinter(WaveView ecgview, PageFormat pageFormat) { this.ecgview = ecgview; Paper paper = pageFormat.getPaper(); double margin = 18; paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, paper.getHeight() - margin * 2); pageFormat.setPaper(paper); setLayout(null); removeAll(); int pageWidth = (int) pageFormat.getWidth(); int pageHeight = (int) pageFormat.getHeight(); this.setPreferredSize(new Dimension(pageWidth, pageHeight)); }
public PhysicalPageBox( final PageFormat pageFormat, final long globalX, final long globalY ) { this.width = StrictGeomUtility.toInternalValue( pageFormat.getWidth() ); this.height = StrictGeomUtility.toInternalValue( pageFormat.getHeight() ); this.imageableX = StrictGeomUtility.toInternalValue( pageFormat.getImageableX() ); this.imageableY = StrictGeomUtility.toInternalValue( pageFormat.getImageableY() ); this.imageableWidth = StrictGeomUtility.toInternalValue( pageFormat.getImageableWidth() ); this.imageableHeight = StrictGeomUtility.toInternalValue( pageFormat.getImageableHeight() ); this.globalX = globalX; this.globalY = globalY; this.orientation = pageFormat.getOrientation(); }