M
marcind
hello
at the begining I wont to apologies everyone because i knew that this
subject was on the group many times but nowhere I could find working example
of solving this problem;
if anyones could help me with printing contents of JEditorPane that containt
html formatted text i would be gratefully.
I manage to print graphic (using drawLine()) but how print JeditorPane ??
thanks for any suggestions.
example printing line :
public class Print2 extends JEditorPane implements Printable
{
public static void main(String[] args) {
Print2 pp= new Print2();
pp.imprimir();
}
public Print2() {
super();
}
public void imprimir()
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public void paintComponent(Graphics g)
{
System.out.println("paintComponent "+g);
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g = (Graphics2D) getComponentGraphics(g2);
g.drawLine(0,0,100,100);
}
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
g = (Graphics2D) getComponentGraphics(g);
g.drawLine(0,0,400,100);
return Printable.PAGE_EXISTS;
}
}
at the begining I wont to apologies everyone because i knew that this
subject was on the group many times but nowhere I could find working example
of solving this problem;
if anyones could help me with printing contents of JEditorPane that containt
html formatted text i would be gratefully.
I manage to print graphic (using drawLine()) but how print JeditorPane ??
thanks for any suggestions.
example printing line :
public class Print2 extends JEditorPane implements Printable
{
public static void main(String[] args) {
Print2 pp= new Print2();
pp.imprimir();
}
public Print2() {
super();
}
public void imprimir()
{
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public void paintComponent(Graphics g)
{
System.out.println("paintComponent "+g);
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g = (Graphics2D) getComponentGraphics(g2);
g.drawLine(0,0,100,100);
}
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
g = (Graphics2D) getComponentGraphics(g);
g.drawLine(0,0,400,100);
return Printable.PAGE_EXISTS;
}
}