Seiten mehrfach ausdrucken

MetroAffe

Mitglied
Moin,

habe das Problem das ich nie mehr als 1 "Kopie" von einem Druckauftrag bekomme ...

und das trotz des Attributes - Copies()

Oder gibt es eine andere, womöglich bessere Lösung?

Java:
	public static void PrintPDF(String printName, String path, int anzahl) {

		PdfDecoder decodePdf = new PdfDecoder(true);

		try {
			decodePdf.openPdfFile(path);
			FontMappings.setFontReplacements();
		} catch (Exception e) {
			e.printStackTrace();
		}

		PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
		JobName jobName = new JobName(printName, null);
		attributeSet.add(jobName);
		attributeSet.add(new Copies(anzahl));
		System.out.println(anzahl);

		decodePdf.setPrintAutoRotateAndCenter(true);
		decodePdf.setPrintPageScalingMode(PrinterOptions.PAGE_SCALING_NONE);

		try {
			decodePdf.setPagePrintRange(1, decodePdf.getPageCount());
		} catch (PdfException e) {
			e.printStackTrace();
		}

		PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, attributeSet);

		for (PrintService s : services) {
			System.out.println(s.getName());
		}

		PrintService printingDevice = null;
		for (PrintService s : services) {
			if (s.getName().equals("Canon MP560 series Printer")) {
				printingDevice = s;
			}
		}

		PdfBook pdfBook = new PdfBook(decodePdf, printingDevice, attributeSet);
		SimpleDoc doc = new SimpleDoc(pdfBook, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);

		DocPrintJob printJob = printingDevice.createPrintJob();

		try {
			printJob.print(doc, attributeSet);

		} catch (PrintException e) {
			e.printStackTrace();
		}
	}

Danke
mfg MetroAffe
 
Hallo, kenne die Api nicht aber wie wäre es mit :

Code:
try {
            for (int i = 0;i <= anzahl; i++ {
                   printJob.print(doc, attributeSet);
            }

        } catch (PrintException e) {
            e.printStackTrace();
        }

Wäre jetzt nur ein Vorschlag. :)
 
Zurück