Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Printing images (on paper), something seems quite off. Lots of code.

$
0
0
Okay, so this is quite a big program but the idea is it draws grids on top of images and prints them out with proportional grids.

Here is the part of the grid that corresponds to printing. This is in the main class.
if(choose.equals("Print Picture")) {
		PrinterJob printJob = PrinterJob.getPrinterJob();
		Book book = new Book();
		book.append(new Picture(), printJob.defaultPage());
		printJob.setPageable(book);
		printJob.printDialog();
		try {
			printJob.print();
		} catch (Exception PrintException) {
			PrintException.printStackTrace();
		}
	}


And on another class
public class Picture implements Printable {
	public int print(Graphics g, PageFormat pageFormat, int page) throws PrinterException {
		g.translate((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY());
		g.drawImage(GridCreator.getmyImg(),0,0,null);
		return PAGE_EXISTS;
	}
}


So when I PRINT the image, it comes out huge on U.S. 8.5 x 11 paper. 1/3 of the image taking up the whole picture. The original image I used was 1280px by 930px.
When I take the same image file and put it in photoshop on U.S. paper document, it looks like this
http://i.imgur.com/DRFrYAf.png

What am I doing wrong?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>