From: <doc...@us...> - 2007-08-29 02:27:35
|
Revision: 163 http://openpcl.svn.sourceforge.net/openpcl/?rev=163&view=rev Author: documentsystems Date: 2007-08-28 19:26:53 -0700 (Tue, 28 Aug 2007) Log Message: ----------- Howard Hoagland. 1. Get the dpi that the print driver of the selected printer picked (examples 300 or 600 or 1200 dpi). 2. Added comment line for centering Legal image on Letter paper. 3. For Legal image on Legal paper (not forcing paper change), bumped the image to the right slightly so that the vertical lines on the left edge of the image won't be chopped off on the left. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java Modified: openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java =================================================================== --- openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-08-29 02:20:53 UTC (rev 162) +++ openpcl/src/com/openpcl/viewer/printing/PosPrintBufferedImage.java 2007-08-29 02:26:53 UTC (rev 163) @@ -38,16 +38,15 @@ private JProgressBar mPrintingProgressBar = null; private static final String sProgressBarBaseString = "Generating page: "; private static final String sCantAllocate = "Can't allocate memory for temporary image used for printing."; + private boolean mShouldSetRendingHints = false; // Printing looks the same on paper if rending hints are set or not private double mPrintScale = 72.0d / 300.0d; // making width and height using 72 / 300 scale private double mPageWidthPixels = 8.5 * 300; private double mShrinkLegalToLetterRatio = (11.0d / 14.0d); // shrink in both directions height 14" to 11" private double mShrinkLegalToLetterScale = mPrintScale * mShrinkLegalToLetterRatio; - private double mShrinkLegalToLetterMargins = 0.27 * 300; - + private double mShrinkLegalToLetterMargins = 0.27d * 300.0d; private double mXOffsetForCenteringShrinkLegalOnLetter = ((mPageWidthPixels - (mPageWidthPixels * mShrinkLegalToLetterRatio)) / 2) + mShrinkLegalToLetterMargins; - private boolean mShouldSetRendingHints = false; // Printing looks the same on paper if rending hints are set or not public PosPrintBufferedImage(PosView pPosView) { super(); @@ -101,16 +100,24 @@ g2D.setPaint(Color.BLACK); // Save the passed in AffineTransform (to put it back before returning) mOrigAffineTransform = g2D.getTransform(); + // The below is the resolution that the selected printer's print driver set, + // and will be 4.1667 on a 300dpi printer, or 8.333 on a 600dpi printer. + // The below 2 lines would help debugging any future problems if different printer resolutions print too small or too big. + // long tDpiSetByPrintDriver = Math.round( mOrigAffineTransform.getScaleX() * 72); + // System.out.println("The print driver selected dpi is " + tDpiSetByPrintDriver ); if (mPosPrintSetupDialogChoices.isPaperSizePrintAllOnLetterShrinksLegal() && ( !(mPosView.getOpenPCLViewer().isTreeNodePageLetterSize(mPrintThisTreeNode)) )) { // The user has clicked the "Print all on Letter paper (shrinks Legal)" radio button so shrink Legal to fit on Letter g2D.transform(mShrinkLegalToLetterAffineTransform); + // Center the Legal image on the Letter page size buy bumping to the right half the available horizontal space g2D.translate(mXOffsetForCenteringShrinkLegalOnLetter, 0.0d); } else { // Set the 72/300 = .24 AffineTransform on the current Graphics2D, to scale smaller to fit exactly on the printed page g2D.transform(mScaleAffineTransform); + // So that the vertical lines at the very left edge aren't chopped off, need to bump the whole image 4 pixels to the right + g2D.translate(4.0d, 0.0d); } // Make the BufferedImage from the tree node. @@ -222,18 +229,32 @@ // import javax.print.attribute.Attribute; // import javax.print.attribute.PrintJobAttributeSet; // import javax.print.attribute.PrintServiceAttributeSet; +// import javax.print.attribute.standard.PrinterMakeAndModel; +// import javax.print.attribute.standard.PrinterName; // import javax.print.attribute.standard.PrinterResolution; // import sun.awt.windows.WPrinterJob; // import sun.print.Win32PrintService; // private PrinterJob mPrinterJob = null; // private DocPrintJob mDocPrintJob = null; +// private PrintService mPrintService = null; // public void setPrinterJob(PrinterJob pPrinterJob) { // mPrinterJob = pPrinterJob; // mDocPrintJob = pPrinterJob.getPrintService().createPrintJob(); // } +// public void setPrintService(PrintService pPrintService) { +// mPrintService = pPrintService; +// } + +// PrintServiceAttributeSet tPas = mPrintService.getAttributes(); +// Attribute tPname = tPas.get(PrinterName.class); // works Ok. It returns the PrinterName that the user can change. +// Attribute tPmm = tPas.get(PrinterMakeAndModel.class); // returns null but shouldn't http://bugs.sun.com/view_bug.do?bug_id=4673400 +// System.out.println("Number of print service attributes: " + tPas.size()); +// System.out.println("Printer name: " + tPname ); +// System.out.println("PrinterMakeAndModel: " + tPmm); + //GraphicsConfiguration tGc = g2D.getDeviceConfiguration(); //ColorModel tColorModel = tGc.getColorModel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |