Here you can find the source of print(PrintService printService, byte[] pdf)
private static void print(PrintService printService, byte[] pdf) throws PrintException
//package com.java2s; /**/*from www . j a va 2s.co m*/ * Copyright ? 2002 Instituto Superior T?cnico * * This file is part of FenixEdu Core. * * FenixEdu Core is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FenixEdu Core is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with FenixEdu Core. If not, see <http://www.gnu.org/licenses/>. */ import javax.print.Doc; import javax.print.DocFlavor; import javax.print.DocPrintJob; import javax.print.PrintException; import javax.print.PrintService; import javax.print.SimpleDoc; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.Sides; public class Main { private static void print(PrintService printService, byte[] pdf) throws PrintException { final DocPrintJob job = printService.createPrintJob(); final Doc doc = new SimpleDoc(pdf, DocFlavor.BYTE_ARRAY.PDF, null); final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(new Copies(1)); aset.add(MediaSizeName.ISO_A4); aset.add(Sides.ONE_SIDED); job.print(doc, aset); } }