Results 1 to 2 of 2
Thread: Printing
- 12-17-2012, 05:36 PM #1
Member
- Join Date
- Feb 2012
- Location
- Norway
- Posts
- 96
- Rep Power
- 0
Printing
Hi,
I have a little problem with my code, and hopefully someone in here can see where I am goin wrong and point me in the right direction...gif)
Here is the code:
And this:Java Code:private void cmdPrintActionPerformed(java.awt.event.ActionEvent evt) { PrinterJob printerJob = PrinterJob.getPrinterJob(); printerJob.setPrintable((Printable) this); boolean doPrint = printerJob.printDialog(); PageFormat pf = printerJob.defaultPage(); Paper paper = pf.getPaper(); paper.setImageableArea(2.0, 2.0, paper.getWidth(), paper.getHeight()); pf.setPaper(paper); if(doPrint){ try { printerJob.print(); } catch (PrinterException ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } this.dispose(); }
The thing is that I print the printPanel, and it doesn't fit the paper.Java Code:public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex > 0) { return(NO_SUCH_PAGE); } else { Graphics2D g2d = (Graphics2D)g; g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); printPanel.print(g); return(PAGE_EXISTS); } }
That is what I want... I have tried a few things, but I am stuck...
- 12-17-2012, 05:59 PM #2
Similar Threads
-
Implement Custom Printing Logic & Enhanced Word Documents Printing
By sherazam in forum Java SoftwareReplies: 0Last Post: 12-26-2011, 03:52 PM -
Help in Printing
By kirly in forum Advanced JavaReplies: 3Last Post: 10-03-2011, 03:40 PM -
Help with printing an arrayList. printing the first element twice
By kingkongjaffa in forum New To JavaReplies: 9Last Post: 08-19-2011, 12:59 AM -
Printing Job
By qwerty53 in forum New To JavaReplies: 2Last Post: 07-19-2011, 03:32 PM -
printing string backwards and printing every other
By droidus in forum New To JavaReplies: 22Last Post: 03-10-2011, 09:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks