Print button in java for creating PDF with dialog box. just copy code and paste in a new java
application to check out this button for pdf generating.
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.
import java.awt.print.
import java.awt.print.
import java.awt.print.
public class PrintableDemo1 im
public int print(Graphics g,
if (pageIndex != 0)
return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2
g2.setFont(new Font("
g2.setPaint(Color.black);
g2.drawString("Java
return PAGE_EXISTS;
}
public static void main(Stri
PrinterJob pj =
pj.setPrintable(new Printa
if (pj.printDialog()) {
try {
pj.print();
} catch (PrinterExceptio
System.out.println(e);
}
}
}
}
No comments:
Post a Comment