java.awt.print.Paper Java Examples

The following examples show how to use java.awt.print.Paper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PSPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public EPSPrinter(Printable printable, String title,
                  PrintStream stream,
                  int x, int y, int wid, int hgt) {

    this.printable = printable;
    this.epsTitle = title;
    this.stream = stream;
    llx = x;
    lly = y;
    urx = llx+wid;
    ury = lly+hgt;
    // construct a PageFormat with zero margins representing the
    // exact bounds of the applet. ie construct a theoretical
    // paper which happens to exactly match applet panel size.
    Paper p = new Paper();
    p.setSize((double)wid, (double)hgt);
    p.setImageableArea(0.0,0.0, (double)wid, (double)hgt);
    pf = new PageFormat();
    pf.setPaper(p);
}
 
Example #2
Source File: PrintManager.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/** @return A newly created {@link PageFormat} with the current settings. */
public PageFormat createPageFormat() {
    PageFormat      format      = new PageFormat();
    PageOrientation orientation = getPageOrientation();
    double[]        size        = getPaperSize(LengthUnits.PT);
    double[]        margins     = getPaperMargins(LengthUnits.PT);
    Paper           paper       = new Paper();

    if (orientation == PageOrientation.PORTRAIT) {
        format.setOrientation(PageFormat.PORTRAIT);
    } else if (orientation == PageOrientation.LANDSCAPE) {
        format.setOrientation(PageFormat.LANDSCAPE);
    } else if (orientation == PageOrientation.REVERSE_PORTRAIT) {
        // REVERSE_PORTRAIT doesn't exist in the old PageFormat class
        format.setOrientation(PageFormat.PORTRAIT);
    } else if (orientation == PageOrientation.REVERSE_LANDSCAPE) {
        format.setOrientation(PageFormat.REVERSE_LANDSCAPE);
    }
    paper.setSize(size[0], size[1]);
    paper.setImageableArea(margins[1], margins[0], size[0] - (margins[1] + margins[3]), size[1] - (margins[0] + margins[2]));
    format.setPaper(paper);
    return format;
}
 
Example #3
Source File: Test.java    From jpexs-decompiler with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    PDFJob job=new PDFJob(new FileOutputStream("test.pdf"));   
    PageFormat pf=new PageFormat();
    pf.setOrientation(PageFormat.PORTRAIT);
    Paper p = new Paper();
    p.setSize(210,297); //A4
    pf.setPaper(p);
    
    BufferedImage img = ImageIO.read(new File("earth.jpg"));
    
    int w = 200;
    
    for(int i=0;i<10;i++){
        Graphics g = job.getGraphics();
        g.drawImage(img, 0, 0,w,w, null);
        g.dispose();
    }
    
    job.end();
}
 
Example #4
Source File: TextFilePrinterDriver.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Resets the printer and starts a new page. Prints the top border lines (if necessary).
 *
 * @throws java.io.IOException
 *           if there was an IOError while writing the command
 */
public void startPage( final Paper paper, final String encoding ) throws IOException {
  this.defaultEncoding = encoding;

  if ( firstPage ) {
    final EncodingUtilities encodingUtilities = getEncodingUtilities( encoding );
    out.write( encodingUtilities.getEncodingHeader() );
    firstPage = false;
  }

  final PageFormatFactory fact = PageFormatFactory.getInstance();
  final float charWidthPoints = 72.0f / getCharactersPerInch();
  borderLeft = (int) ( fact.getLeftBorder( paper ) / charWidthPoints );

  final float lineHeightPoints = 72.0f / getLinesPerInch();
  final int borderTop = (int) ( fact.getTopBorder( paper ) / lineHeightPoints );

  for ( int i = 0; i < borderTop; i++ ) {
    startLine();
    endLine( false );
  }
}
 
Example #5
Source File: PSPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public EPSPrinter(Printable printable, String title,
                  PrintStream stream,
                  int x, int y, int wid, int hgt) {

    this.printable = printable;
    this.epsTitle = title;
    this.stream = stream;
    llx = x;
    lly = y;
    urx = llx+wid;
    ury = lly+hgt;
    // construct a PageFormat with zero margins representing the
    // exact bounds of the applet. ie construct a theoretical
    // paper which happens to exactly match applet panel size.
    Paper p = new Paper();
    p.setSize((double)wid, (double)hgt);
    p.setImageableArea(0.0,0.0, (double)wid, (double)hgt);
    pf = new PageFormat();
    pf.setPaper(p);
}
 
Example #6
Source File: PageFormatSerializer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Restores a page format after it has been serialized.
 *
 * @param data the serialized page format data.
 * @return the restored page format.
 */
private PageFormat createPageFormat( final Object[] data ) {
  final Integer orientation = (Integer) data[ 0 ];
  final float[] dim = (float[]) data[ 1 ];
  final float[] rect = (float[]) data[ 2 ];
  final Paper p = new Paper();
  p.setSize( dim[ 0 ], dim[ 1 ] );
  p.setImageableArea( rect[ 0 ], rect[ 1 ], rect[ 2 ], rect[ 3 ] );
  final PageFormat format = new PageFormat();
  format.setPaper( p );
  format.setOrientation( orientation.intValue() );
  return format;
}
 
Example #7
Source File: PrintPreferencesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testGetPageFormat() {
    PrinterJob pj = PrinterJob.getPrinterJob();
    PageFormat expResult = PrintPreferences.getPageFormat(pj);
    PrintPreferences.setPageFormat(expResult);
    PageFormat result = PrintPreferences.getPageFormat(pj);
    assertEquals(expResult.getHeight(), result.getHeight());
    assertEquals(expResult.getWidth(), result.getWidth());
    assertEquals(expResult.getOrientation(), result.getOrientation());
    assertEquals(expResult.getPaper().getHeight(), result.getPaper().getHeight());
    assertEquals(expResult.getPaper().getWidth(), result.getPaper().getWidth());
    assertEquals(expResult.getPaper().getImageableHeight(), result.getPaper().getImageableHeight());
    assertEquals(expResult.getPaper().getImageableWidth(), result.getPaper().getImageableWidth());
    assertEquals(expResult.getPaper().getImageableX(), result.getPaper().getImageableX());
    assertEquals(expResult.getPaper().getImageableY(), result.getPaper().getImageableY());
    
    double w = expResult.getPaper().getWidth() + 10;
    double h = expResult.getPaper().getHeight() + 10;
    Paper p = expResult.getPaper();
    double ix = p.getImageableX() + 10;
    double iy = p.getImageableY() + 10;
    double iw = p.getImageableWidth() + 10;
    double ih = p.getImageableHeight() + 10;
    p.setImageableArea(ix, iy, iw, ih);
    p.setSize(w, h);
    expResult.setPaper(p);
    PrintPreferences.setPageFormat(expResult);
    assertEquals(h, PrintPreferences.getPageFormat(pj).getHeight());
    assertEquals(w, PrintPreferences.getPageFormat(pj).getWidth());
    assertEquals(ix, PrintPreferences.getPageFormat(pj).getPaper().getImageableX());
    assertEquals(iy, PrintPreferences.getPageFormat(pj).getPaper().getImageableY());
    assertEquals(iw, PrintPreferences.getPageFormat(pj).getPaper().getImageableWidth());
    assertEquals(ih, PrintPreferences.getPageFormat(pj).getPaper().getImageableHeight());
    
    expResult.setOrientation(PageFormat.REVERSE_LANDSCAPE);
    PrintPreferences.setPageFormat(expResult);
    assertEquals(PageFormat.REVERSE_LANDSCAPE, PrintPreferences.getPageFormat(pj).getOrientation());
}
 
Example #8
Source File: PageDefinitionModelReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Starts parsing.
 *
 * @param attrs the attributes.
 * @throws SAXException if there is a parsing error.
 */
protected void startParsing( final Attributes attrs ) throws SAXException {
  final Dimension2D pageSize = DoubleDimensionConverter.getObject( attrs.getValue( getUri(), "pageSize" ) );
  final double topBorder = Double.parseDouble( attrs.getValue( getUri(), "topBorder" ) );
  final double leftBorder = Double.parseDouble( attrs.getValue( getUri(), "leftBorder" ) );
  final double bottomBorder = Double.parseDouble( attrs.getValue( getUri(), "bottomBorder" ) );
  final double rightBorder = Double.parseDouble( attrs.getValue( getUri(), "rightBorder" ) );

  final Paper paper = PageFormatFactory.getInstance().createPaper( pageSize.getWidth(), pageSize.getHeight() );
  PageFormatFactory.getInstance().setBorders( paper, topBorder, leftBorder, bottomBorder, rightBorder );

  pageFormat = new PageFormat();
  pageFormat.setPaper( paper );

}
 
Example #9
Source File: RasterPrinterJob.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example #10
Source File: IBMCompatiblePrinterDriver.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Resets the printer and starts a new page. Prints the top border lines (if necessary).
 *
 * @throws java.io.IOException
 *           if there was an IOError while writing the command
 */
public void startPage( final Paper paper, final String encoding ) throws IOException {
  this.encoding = encoding;
  final float charWidthPoints = 72.0f / getCharactersPerInch();
  final float lineHeightPoints = 72.0f / getLinesPerInch();

  if ( firstPage ) {
    // update the autoLF setting
    sendAutoLF( isAutoLF() );
    sendDefinePrintQuality( getPrintQuality() );
    sendDefineCharacterWidth( getCharactersPerInch() );
    firstPage = false;
  }

  // set the line spacing ..
  sendLineSpacing( (int) lineHeightPoints );

  // define the page size ..
  // we redefine it for every page, as we do not assume that the page sizes
  // will be the same for the whole report.
  final int lines = (int) ( ( paper.getHeight() / 72.0f ) * getLinesPerInch() );
  sendDefinePageLengthInLines( lines );

  final PageFormatFactory fact = PageFormatFactory.getInstance();
  final int borderLeft = (int) ( fact.getLeftBorder( paper ) / charWidthPoints );
  final int borderRight = (int) ( fact.getRightBorder( paper ) / charWidthPoints );

  final int borderTop = (int) ( fact.getTopBorder( paper ) / lineHeightPoints );
  sendDefineHorizontalBorders( borderLeft, borderRight );

  // print the top margin ..
  for ( int i = 0; i < borderTop; i++ ) {
    startLine();
    endLine( false );
  }

}
 
Example #11
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example #12
Source File: PageDefinitionReadHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Handles the page format.
 *
 * @param atts
 *          the attributes.
 * @throws SAXException
 *           if a parser error occurs or the validation failed.
 * @noinspection SuspiciousNameCombination
 */
private PageFormat configurePageSizeAndMargins( final Attributes atts, PageFormat format ) throws SAXException {
  // (1) Grab the existing default ...
  float defTopMargin = (float) format.getImageableY();
  float defBottomMargin = (float) ( format.getHeight() - format.getImageableHeight() - format.getImageableY() );
  float defLeftMargin = (float) format.getImageableX();
  float defRightMargin = (float) ( format.getWidth() - format.getImageableWidth() - format.getImageableX() );

  // (2) Now configure the new paper-size
  format = configurePageSize( format, atts );

  // (3) Reconfigure margins as requested
  defTopMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-top" ), defTopMargin );
  defBottomMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-bottom" ), defBottomMargin );
  defLeftMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-left" ), defLeftMargin );
  defRightMargin = ParserUtil.parseFloat( atts.getValue( getUri(), "margin-right" ), defRightMargin );

  final Paper p = format.getPaper();
  switch ( format.getOrientation() ) {
    case PageFormat.PORTRAIT:
      PageFormatFactory.getInstance().setBorders( p, defTopMargin, defLeftMargin, defBottomMargin, defRightMargin );
      break;
    case PageFormat.REVERSE_LANDSCAPE:
      PageFormatFactory.getInstance().setBorders( p, defLeftMargin, defBottomMargin, defRightMargin, defTopMargin );
      break;
    case PageFormat.LANDSCAPE:
      PageFormatFactory.getInstance().setBorders( p, defRightMargin, defTopMargin, defLeftMargin, defBottomMargin );
      break;
    default:
      // will not happen..
      throw new IllegalArgumentException( "Unexpected paper orientation." );
  }

  format.setPaper( p );
  return format;
}
 
Example #13
Source File: TextDocumentWriter.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void processPhysicalPage( final PageGrid pageGrid, final LogicalPageBox logicalPage, final int row,
    final int col, final PhysicalPageKey pageKey ) throws IOException {
  final PhysicalPageBox page = pageGrid.getPage( row, col );
  final Paper paper = new Paper();
  paper.setSize( StrictGeomUtility.toExternalValue( page.getWidth() ), StrictGeomUtility.toExternalValue( page
      .getHeight() ) );
  paper.setImageableArea( StrictGeomUtility.toExternalValue( page.getImageableX() ), StrictGeomUtility
      .toExternalValue( page.getImageableY() ), StrictGeomUtility.toExternalValue( page.getImageableWidth() ),
      StrictGeomUtility.toExternalValue( page.getImageableHeight() ) );
  drawArea = new StrictBounds( page.getGlobalX(), page.getGlobalY(), page.getWidth(), page.getHeight() );
  plainTextPage = new PlainTextPage( paper, driver, encoding );
  processPageBox( logicalPage );
  plainTextPage.writePage();
}
 
Example #14
Source File: PlainTextPage.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a new PlainTextPage with the given dimensions and the specified PrinterCommandSet.
 *
 * @param driver
 *          the command-set for printing and formatting the text.
 */
public PlainTextPage( final Paper pageFormat, final PrinterDriver driver, final String defaultEncoding ) {
  if ( driver == null ) {
    throw new NullPointerException( "PrinterCommandSet must be defined." );
  }
  if ( pageFormat == null ) {
    throw new NullPointerException( "PageFormat must be defined." );
  }
  if ( defaultEncoding == null ) {
    throw new NullPointerException( "DefaultEncoding must be defined." );
  }

  final float characterWidthInPoint = ( 72.0f / driver.getCharactersPerInch() );
  final float characterHeightInPoint = ( 72.0f / driver.getLinesPerInch() );

  final int currentPageHeight =
      PlainTextPage.correctedDivisionFloor( pageFormat.getImageableHeight(), characterHeightInPoint );
  final int currentPageWidth =
      PlainTextPage.correctedDivisionFloor( pageFormat.getImageableWidth(), characterWidthInPoint );

  // Log.debug("Created page with " + currentPageWidth + ", " + currentPageHeight);
  pageBuffer = new PlaintextDataChunk[currentPageWidth][currentPageHeight];
  width = currentPageWidth;
  height = currentPageHeight;
  paper = pageFormat;
  this.driver = driver;
  this.defaultEncoding = defaultEncoding;
}
 
Example #15
Source File: SurveyScaleAPIDemoHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a report format by calling API methods directly.
 *
 * @return A report.
 */
public MasterReport createReport()
{

  final MasterReport report = new MasterReport();
  report.setName("Survey Scale Demo Report");

  // use A4...
  final PageFormatFactory pff = PageFormatFactory.getInstance();
  final Paper paper = pff.createPaper(PageSize.A4);
  pff.setBorders(paper, PAGE_MARGIN_TOP, PAGE_MARGIN_LEFT, PAGE_MARGIN_BOTTOM, PAGE_MARGIN_RIGHT);
  final PageFormat format = pff.createPageFormat(paper, PageFormat.PORTRAIT);
  report.setPageDefinition(new SimplePageDefinition(format));

  setupWatermark(report);
  setupPageHeader(report);
  //// REPORT GROUP /////////////////////////////////////////////////////////////////////////
  setupGroup(report);
  //// ITEM BAND ////////////////////////////////////////////////////////////////////////////
  setupItemBand(report);
  //// PAGE FOOTER //////////////////////////////////////////////////////////////////////////
  setupPageFooter(report);

  report.getParameterValues().put("RESPONDENT_NAME", "Dave");
  report.setDataFactory(new TableDataFactory
      ("default", data));
  return report;
}
 
Example #16
Source File: WPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPrintableY(Paper p) {
    return mPrintPhysY;
}
 
Example #17
Source File: WPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPageHeight(Paper p) {
    return mPageHeight;
}
 
Example #18
Source File: WPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPageHeight(Paper p) {
    return mPageHeight;
}
 
Example #19
Source File: WPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPrintableX(Paper p) {
    return mPrintPhysX;
}
 
Example #20
Source File: WPrinterJob.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPrintableWidth(Paper p) {
    return mPrintWidth;
}
 
Example #21
Source File: TextEditor.java    From groovy with Apache License 2.0 4 votes vote down vote up
public int getNumberOfPages() {
    Paper paper = PAGE_FORMAT.getPaper();
    numPages = (int) Math.ceil(getSize().getHeight() / paper.getImageableHeight());
    return numPages;
}
 
Example #22
Source File: PrintJob2D.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public boolean printDialog() {

        boolean proceedWithPrint = false;

        printerJob = PrinterJob.getPrinterJob();
        if (printerJob == null) {
            return false;
        }
        DialogType d = this.jobAttributes.getDialog();
        PrintService pServ = printerJob.getPrintService();
        if ((pServ == null) &&  (d == DialogType.NONE)){
            return false;
        }
        copyAttributes(pServ);

        DefaultSelectionType select =
            this.jobAttributes.getDefaultSelection();
        if (select == DefaultSelectionType.RANGE) {
            attributes.add(SunPageSelection.RANGE);
        } else if (select == DefaultSelectionType.SELECTION) {
            attributes.add(SunPageSelection.SELECTION);
        } else {
            attributes.add(SunPageSelection.ALL);
        }

        if (frame != null) {
             attributes.add(new DialogOwner(frame));
         }

        if ( d == DialogType.NONE) {
            proceedWithPrint = true;
        } else {
            if (d == DialogType.NATIVE) {
                attributes.add(DialogTypeSelection.NATIVE);
            }  else { //  (d == DialogType.COMMON)
                attributes.add(DialogTypeSelection.COMMON);
            }
            if (proceedWithPrint = printerJob.printDialog(attributes)) {
                if (pServ == null) {
                    // Windows gives an option to install a service
                    // when it detects there are no printers so
                    // we make sure we get the updated print service.
                    pServ = printerJob.getPrintService();
                    if (pServ == null) {
                        return false;
                    }
                }
                updateAttributes();
                translateOutputProps();
            }
        }

        if (proceedWithPrint) {

            JobName jname = (JobName)attributes.get(JobName.class);
            if (jname != null) {
                printerJob.setJobName(jname.toString());
            }

            pageFormat = new PageFormat();

            Media media = (Media)attributes.get(Media.class);
            MediaSize mediaSize =  null;
            if (media != null  && media instanceof MediaSizeName) {
                mediaSize = MediaSize.getMediaSizeForName((MediaSizeName)media);
            }

            Paper p = pageFormat.getPaper();
            if (mediaSize != null) {
                p.setSize(mediaSize.getX(MediaSize.INCH)*72.0,
                          mediaSize.getY(MediaSize.INCH)*72.0);
            }

            if (pageAttributes.getOrigin()==OriginType.PRINTABLE) {
                // AWT uses 1/4" borders by default
                p.setImageableArea(18.0, 18.0,
                                   p.getWidth()-36.0,
                                   p.getHeight()-36.0);
            } else {
                p.setImageableArea(0.0,0.0,p.getWidth(),p.getHeight());
            }

            pageFormat.setPaper(p);

            OrientationRequested orient =
               (OrientationRequested)attributes.get(OrientationRequested.class);
            if (orient!= null &&
                orient == OrientationRequested.REVERSE_LANDSCAPE) {
                pageFormat.setOrientation(PageFormat.REVERSE_LANDSCAPE);
            } else if (orient == OrientationRequested.LANDSCAPE) {
                pageFormat.setOrientation(PageFormat.LANDSCAPE);
            } else {
                pageFormat.setOrientation(PageFormat.PORTRAIT);
                }

            printerJob.setPrintable(this, pageFormat);

        }

        return proceedWithPrint;
    }
 
Example #23
Source File: AbstractEpsonPrinterDriver.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Resets the printer and starts a new page. Prints the top border lines (if necessary).
 *
 * @throws java.io.IOException
 *           if there was an IOError while writing the command
 */
public void startPage( final Paper paper, final String encoding ) throws IOException {
  this.encoding = encoding;
  final float lineHeightPoints = 72.0f / getLinesPerInch();
  final float charWidthPoints = 72.0f / getCharactersPerInch();

  // Quoted from the Epson Reference Manual page R-4:

  // 1. Send an ESC @ to initialize the printer
  sendResetPrinter();
  driverState.reset();

  // 2. Set the unit of line spacing to the minimum vertical increment necessary
  sendDefineLineSpacing( lineHeightPoints );

  // 3. Set the printing area
  final int lines = (int) ( ( paper.getHeight() / 72.0f ) * getLinesPerInch() );
  sendDefinePageLengthInLines( lines );

  sendDefineCharacterWidth( getCharactersPerInch() );

  final PageFormatFactory fact = PageFormatFactory.getInstance();
  final int borderLeft = (int) ( fact.getLeftBorder( paper ) / charWidthPoints );
  final int borderRight = (int) ( fact.getRightBorder( paper ) / charWidthPoints );
  sendDefineHorizontalBorders( borderLeft, borderRight );

  final int borderTop = (int) ( fact.getTopBorder( paper ) / lineHeightPoints );
  // borderBottom = (int) (fact.getBottomBorder(paper) / lineHeightPoints);

  // print the top margin ..
  for ( int i = 0; i < borderTop; i++ ) {
    startLine();
    endLine( false );
  }

  // 4. Assign character tables to each of the four active tables as
  // necessary. (ESC/P2 printers only)
  //
  // this is done before we start printing the text (and may change mid-page).
  // sendDefineCodepage(encoding);

  // 5. Define any user-defined characters.
  //
  // this is done before we start printing the text (and may change mid-page).
  // sendDefineUserCharacters();
}
 
Example #24
Source File: WPrinterJob.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPrintableWidth(Paper p) {
    return mPrintWidth;
}
 
Example #25
Source File: WPrinterJob.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPrintableHeight(Paper p) {
    return mPrintHeight;
}
 
Example #26
Source File: WPrinterJob.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPageWidth(Paper p) {
    return mPageWidth;
}
 
Example #27
Source File: WPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected double getPhysicalPageHeight(Paper p) {
    return mPageHeight;
}
 
Example #28
Source File: PSPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected double getPhysicalPrintableWidth(Paper p) {
    return p.getImageableWidth();
}
 
Example #29
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * updates a Paper object to reflect the current printer's selected
 * paper size and imageable area for that paper size.
 * Default implementation copies settings from the original, applies
 * applies some validity checks, changes them only if they are
 * clearly unreasonable, then sets them into the new Paper.
 * Subclasses are expected to override this method to make more
 * informed decisons.
 */
protected void validatePaper(Paper origPaper, Paper newPaper) {
    if (origPaper == null || newPaper == null) {
        return;
    } else {
        double wid = origPaper.getWidth();
        double hgt = origPaper.getHeight();
        double ix = origPaper.getImageableX();
        double iy = origPaper.getImageableY();
        double iw = origPaper.getImageableWidth();
        double ih = origPaper.getImageableHeight();

        /* Assume any +ve values are legal. Overall paper dimensions
         * take precedence. Make sure imageable area fits on the paper.
         */
        Paper defaultPaper = new Paper();
        wid = ((wid > 0.0) ? wid : defaultPaper.getWidth());
        hgt = ((hgt > 0.0) ? hgt : defaultPaper.getHeight());
        ix = ((ix > 0.0) ? ix : defaultPaper.getImageableX());
        iy = ((iy > 0.0) ? iy : defaultPaper.getImageableY());
        iw = ((iw > 0.0) ? iw : defaultPaper.getImageableWidth());
        ih = ((ih > 0.0) ? ih : defaultPaper.getImageableHeight());
        /* full width/height is not likely to be imageable, but since we
         * don't know the limits we have to allow it
         */
        if (iw > wid) {
            iw = wid;
        }
        if (ih > hgt) {
            ih = hgt;
        }
        if ((ix + iw) > wid) {
            ix = wid - iw;
        }
        if ((iy + ih) > hgt) {
            iy = hgt - ih;
        }
        newPaper.setSize(wid, hgt);
        newPaper.setImageableArea(ix, iy, iw, ih);
    }
}
 
Example #30
Source File: PSPrinterJob.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected double getPhysicalPrintableHeight(Paper p) {
    return p.getImageableHeight();
}