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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.