0

Hello everyone I am trying to print out a load of printables on different pages, I have made the containing class Pageable, and implemented all the methods as below, the acutal printing is done in printAllGraphs() :

PrinterJob printerJob;
	PageFormat pageFormat;
	int numberOfPages;

	public void printAllGraphs(){
		//this.chart.print();
		numberOfPages=this.dataList.size();
		System.out.println("Number of pages : " + numberOfPages);
		
		printerJob = PrinterJob.getPrinterJob();
		printerJob.setJobName(" Print Component ");
		printerJob.setPageable(this);
		setPageFormat();
		if (printerJob.printDialog() == false)
			return;
		
		try {
			printerJob.print();
		} catch (PrinterException ex) {
			System.err.println(ex.getMessage());
		}
	}
	
	public int getNumberOfPages() {
		return numberOfPages;
	}
	
	public void setPageFormat()
	{
		pageFormat = printerJob.pageDialog(printerJob.defaultPage());
	}
	
	public PageFormat getPageFormat(int pageNumber)
                          throws IndexOutOfBoundsException {
		return pageFormat;
	}
	
	public Printable getPrintable(int pageNumber) throws IndexOutOfBoundsException {
		System.out.println("Getting printable for page : "+pageNumber);
		System.out.println("Returning " + chart.chartPanel);
		return chart.chartPanel;
	}

My problem is that its only printing the first page, which it does fine. Here is an example of the output:

Number of pages : 3
Getting printable for page : 0
Returning saiman.uiobjnew.DynamicChartPanel[...]
Getting printable for page : 1
Returning saiman.uiobjnew.DynamicChartPanel[...]

as you can see, its getting the printable for page 0 and 1 fine, but there are three pages and it never tries to get one for the last page, so i can assume its failed somehow before printing the second page and just given up (resulting in my one page document)

I was wondering if anyone with any experience printing could take a look, see if i am doing anything wrong.

Thanks

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by hanvyj
0

hmm, I made my new printable interface (and just printed some text) and it worked fine, it must be a problem with JFreeChart's printable implementation...

I'm gonnna mark it as solved, even though it isnt because it seems to be a problem with JFreechart and thus out of my hands

Edited by hanvyj: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.