i want the contents of a textarea to be printed.
if the contents span several pages , it should be printed correspodingly.
please help me ,this is urgent.
d j kaladhar
Printable View
i want the contents of a textarea to be printed.
if the contents span several pages , it should be printed correspodingly.
please help me ,this is urgent.
d j kaladhar
i am also not able to
print beyond my first page. the
following is a snippet of my code
and if you have any suggestions as
to how i can make this work, i truly
do appreciate it:
try
{
PrintJob pj = getToolkit().getPrintJob(this, "HELLO", new Properties());
if (pj != null)
{
Graphics g = pj.getGraphics();
g.setFont(new Font("Courier New", Font.PLAIN, 10));
g.setColor(java.awt.Color.white);
int pageWidth = pj.getPageDimension().width;
int pageHeight = pj.getPageDimension().height;
System.out.println("WIDTH = " + pageWidth);
System.out.println("HEIGHT = " + pageHeight);
g.fillRect(0,0,pageWidth, pageHeight);//xMax-xMin,yMax-yMin);
_summaryPanel.setBackground(java.awt.Color.white);
_summaryPanel.printAll(g);//ok
g.dispose();
pj.end();
Graphics g2 = pj.getGraphics();
g2.setFont(new Font("Courier New", Font.PLAIN, 10));
g2.setColor(java.awt.Color.black);
_summaryPanel.setBackground(java.awt.Color.white);
_summaryPanel.printAll(g2);//ok
g2.dispose();
pj.end();
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
try to take off your first pj.end();
Hi,
How would you calculate the no. of pages to be
printed using a TextArea component?
Thanks,
Kannan
The quick and dirty way would be to compute the total length of the text in the TextArea and divide it by the length of a page. Lengths being in pixels. However that could miss the case where a line will be split at the page end and would need to be carried to the next page. Use the FontMetrics class to get the size of the characters being printed.
Norm
Hey, take a look to www.nevaobject.com. This company offers for free some libraries that match exact your need. In few word there is about some libraries that make call API functions. Take a look for the JPrint.
Try it. it works
javalicious
P.S. Sorry for my english