pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gyenes István <gist...@mve.hu>
Subject Re: PDDocument getPrintable endless loop
Date Thu, 21 Nov 2013 08:02:50 GMT
Dear Gilad Denneboom,

thank you advices, I modify my code, but it still not working.
The print command looping and newer end. Not one page send to printer, 
unending page number is sending.
This is my code now:
         PDDocument pdf = 
PDDocument.load("c:\\Java\\nb74_projects\\lpu\\AISB08.pdf");
         PrintService[] ps = PrinterJob.lookupPrintServices();
         int x=0;
         for (x=0; x<ps.length; x++)  if 
(ps[x].getName().compareTo("Canon Generic PCL6 Driver")==0) break;
         PrinterJob pj = PrinterJob.getPrinterJob();
         pj.setPrintService(ps[x]);
         PrintRequestAttributeSet pset = new HashPrintRequestAttributeSet();
         pset.add(MediaTray.TOP);
         pj.setPrintable(pdf.getPrintable(0));
         System.out.println("print start");
         pj.print(pset);
         System.out.println("this message never appear");

Anybody know how should I print one page from a pdf to a specified tray?



Üdvözlettel:
--
*Gyenes István*
Oracle DBA
Tel: 06-20-934-78-40
E-mail: gistvan@mve.hu

*LIBRA Szoftver ZRt.*
1113 Bp. Karolina út 65.
Tel: 06-1-372-3333
Fax: 06-1-209-1477
Web: www.mve.hu
E-mail: info@mve.hu

2013.11.20. 16:53 keltezéssel, Gilad Denneboom írta:
> Not sure why it's happening, but why not add a break command when you find
> the printer you want to print to (after you sent the print command, of
> course)?
> Also, Java arrays are zero-based, so the initial value of x should probably
> be 0, not 1.
>
>
> On Wed, Nov 20, 2013 at 4:26 PM, Gyenes István <gistvan@mve.hu> wrote:
>
>> Hi All!
>>
>> I'm new in BDFBox.
>> I try to print one page to specified tray, but it is make an endless
>> printing loop. I do something wrong or it is a bug in the library?
>> My source code is:
>>   PDDocument pdf = PDDocument.load("c:\\Java\\nb74_projects\\lpu\\AISB08.
>> pdf");
>>          PrintService[] ps = PrinterJob.lookupPrintServices();
>>          for (int x=1; x<ps.length; x++) {
>>              System.out.println(ps[x].getName());
>>              if (ps[x].getName().compareTo("Canon Generic PCL6
>> Driver")==0) {
>>                  PrinterJob pj = PrinterJob.getPrinterJob();
>>                  pj.setPrintService(ps[x]);
>>                  PrintRequestAttributeSet pset = new
>> HashPrintRequestAttributeSet();
>>                  pset.add(MediaTray.TOP);
>>                  pj.setPrintable(pdf.getPrintable(0));
>>                  pj.print(pset);
>>              }
>>          }
>>
>> Big thanks for any help!
>> Stephen Gyenes
>>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message