Yes, we could do with an example, there are multiple ways in which you can use PDFPrinter, it’s pretty flexible. For now here’s some code for simple usage:
PDFPrinter printer = new PDFPrinter(document); PrinterJob job = PrinterJob.getPrinterJob(); printer.silentPrint(job); -- John > On 11 Nov 2014, at 21:49, Imran Akbar <[email protected]> wrote: > > John, > > it would be great if you could provide an example implementing it. > > Thanks, > Imran > > On Tue, Nov 11, 2014 at 9:15 PM, John Hewson <[email protected]> wrote: > >> Sorry, I should have mentioned, we moved this functionality to the >> PDFPrinter class in 2.0. >> >> -- John >> >>> On 11 Nov 2014, at 08:13, Imran Akbar <[email protected]> wrote: >>> >>> Tilman, >>> >>> I tried viewing the pdf from commandline the pdf displayed correctly. >>> >>> John, >>> >>> I downloaded 2.0 from the link [ >>> >> http://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.0-SNAPSHOT/ >> ] >>> but i couldnt find the silentprint method available :( >>> >>> >>> Thanks, >>> Imran >>> >>> >>> >>> On Sun, Nov 9, 2014 at 8:11 PM, John Hewson <[email protected]> wrote: >>> >>>> Printing in 1.8 has a number of bugs and limitations which have been >> fixed >>>> in the 2.0 trunk on SVN, so you might want to try that. >>>> >>>> -- John >>>> >>>>> On 9 Nov 2014, at 00:12, Imran Akbar <[email protected]> wrote: >>>>> >>>>> Hi all, >>>>> >>>>> I am trying to load a pdf from URL/FIle and do a silent print by >> choosing >>>>> the default printer. it prints but the printed output is having issues >> in >>>>> the alignment, if documents contains Footers, they are getting stripped >>>> off >>>>> and not getting printed. is there a way to set the printing properties >>>>> before we print the document when loading an existing document. Please >>>> find >>>>> my below code, >>>>> >>>>> ****** >>>>> >>>>> public class PrintPdf { >>>>> >>>>> public static PrintService choosePrinter() { >>>>> PrinterJob printJob = PrinterJob.getPrinterJob(); >>>>> if (printJob.printDialog()) { >>>>> return printJob.getPrintService(); >>>>> } else { >>>>> return null; >>>>> } >>>>> } >>>>> >>>>> public static void printPDF(String fileName, PrintService printer) >>>>> throws IOException, PrinterException { >>>>> PrinterJob job = PrinterJob.getPrinterJob(); >>>>> job.setPrintService(printer); >>>>> >>>>> PDDocument doc = PDDocument.load(fileName); >>>>> >>>>> doc.silentPrint(job); >>>>> } >>>>> >>>>> public static void main(String[] args) throws IOException, >>>>> PrinterException { >>>>> >>>>> printPDF("http://localhost/IS1330900025_3705.pdf", >>>> choosePrinter()); >>>>> } >>>>> >>>>> } >>>>> >>>>> **** >>>>> >>>>> - Imran >>>> >>> >>> >>> >>> -- >>> -- Imran Akbar >> >> > > > -- > -- Imran Akbar

