• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

printing to multiple of pages

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I've looked on the different tutorial and I can't find any thing that I understand so I would be happy for any answer I get.
This is my code, the problem is that it not printout on multiple pages so all lines does not being printed.
public void pprint()
{
PrinterJob printerJob = PrinterJob.getPrinterJob();
PageFormat formating = new PageFormat();
formating = printerJob.pageDialog(formating);
book = new Book();
book.append(this, formating);
printerJob.setPageable(book);
boolean doPrint = printerJob.printDialog();
if (doPrint)
{
try
{
printerJob.print();
}
catch (PrinterException exception)
{
System.err.println("Printing error: " + exception);
}
}
}
public int print(Graphics g, PageFormat format, int pageIndex)
{
Graphics2D g2d = (Graphics2D) g;
g2d.translate(format.getImageableX(), format.getImageableY());
g2d.setPaint(Color.black);
int y = 15;
for(int j = 0; j < sumOfRows; j++)
{
if(!text[j].getText().equals(""))
{
int lineLength = text[j].getText().length();
if (lineLength > 55)
{
String temp1 = text[j].getText().substring(0, 55);
String temp2 = text[j].getText().substring(56, lineLength);
g2d.drawString(temp1, 15, y);
y += 15;
g2d.drawString(temp2, 15, y);
}
else
g2d.drawString(text[j].getText(), 15, y);
}
y += 15;
}
return Printable.PAGE_EXISTS;
}

Would be happy for answer
Mattias Fransson
 
You got style baby! More than this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic