That’s a shame, I can confirm that it works for me on OS X with Sun’s JDK.

— John

> On 12 May 2015, at 06:58, Gregor Kovač <[email protected]> wrote:
> 
> Hi!
> 
> I've updates my trunk source, compiles it, used it, but it still only
> prints one copy.
> 
> Best regards,
>    Kovi
> 
> 2015-05-12 9:50 GMT+02:00 John Hewson <[email protected]>:
> 
>> So I took another look at this and I think there’s a bug in PDFPrinter
>> where the
>> attributes are being discarded after showing the print dialog.
>> 
>> I’ve made a commit in PDFBOX-2795 which hopefully fixes it, you’ll need to
>> fetch the latest trunk via SVN.
>> 
>> — John
>> 
>>> On 12 May 2015, at 00:13, Gregor Kovač <[email protected]> wrote:
>>> 
>>> Hi!
>>> 
>>> That is a bit strange, since using lpr command work OK for the same
>> printer.
>>> I decided to use SumatraPDF.exe on Windows and lpr on Linux for printing
>>> multiple copies.
>>> 
>>> Thanks for your help guys.
>>> 
>>> Best regards,
>>>   Kovi
>>> 
>>> 2015-05-12 0:54 GMT+02:00 John Hewson <[email protected]>:
>>> 
>>>> Your code looks fine, I suspect that as you say, the problem is with
>>>> Java’s interaction with your printer driver, especially as you’re having
>>>> the same problem with other libraries.
>>>> 
>>>> — John
>>>> 
>>>>> On 8 May 2015, at 17:00, Gregor Kovač <[email protected]> wrote:
>>>>> 
>>>>> Hi!
>>>>> 
>>>>> John, maybe it was, but I still get only one page printed out.
>>>>> I'm using this code:
>>>>> private static void printWithPDFBox2(File pdfFile, int copies) {
>>>>>      PDDocument document = null;
>>>>> 
>>>>>      try {
>>>>>          document = PDDocument.load(pdfFile);
>>>>> 
>>>>>          PrinterJob printJob = PrinterJob.getPrinterJob();
>>>>>          printJob.setJobName(pdfFile.getName());
>>>>> 
>>>>> 
>> printJob.setPrintService(PrintServiceLookup.lookupDefaultPrintService());
>>>>> 
>>>>>          printJob.setCopies(copies);
>>>>>          HashPrintRequestAttributeSet printRequestAttributeSet = new
>>>>> HashPrintRequestAttributeSet();
>>>>>          printRequestAttributeSet.add(new Copies(copies));
>>>>>          printRequestAttributeSet.add(SheetCollate.COLLATED);
>>>>>          PDFPrinter printer = new PDFPrinter(document,
>>>>> Scaling.ACTUAL_SIZE, Orientation.AUTO);
>>>>>          printer.print(printJob, printRequestAttributeSet);
>>>>>      } catch (Exception e) {
>>>>>          e.printStackTrace();
>>>>>      } finally {
>>>>>          if (document != null) {
>>>>>              try {
>>>>>                  document.close();
>>>>>              } catch (Exception e) {
>>>>>                  e.printStackTrace();
>>>>>              }
>>>>>          }
>>>>>      }
>>>>>  }
>>>>> 
>>>>> When the print dialog is displayed I see field "Number of copies:" set
>>>> to 5
>>>>> and "Collate" is checked, but, again, only one page is printed out.
>>>>> 
>>>>> I've tried with Java products for working with PDF that cost thousands
>>>> od $
>>>>> and also only get one page out. It is something with my printer or
>>>>> something in Java.
>>>>> I'm working on Linux, so I'm using cups-pdf package that provides a PDF
>>>>> printer. So, I'm printing PDF files via Java and I get out a PDF file.
>> :)
>>>>> If I use the code above, I get a PDF file with one page, but if I do:
>>>> "lpr
>>>>> -#5 -o Collate=True example.pdf" I get a PDF with 5 pages, becuase
>>>>> example.pdf has only one page.
>>>>> 
>>>>> Any ideas why I'm getting one page PDF in Java?
>>>>> 
>>>>> Best regards,
>>>>>  Kovi
>>>>> 
>>>>> 2015-05-08 23:40 GMT+02:00 John Hewson <[email protected]>:
>>>>> 
>>>>>> This has been fixed in 2.0:
>>>>>> 
>>>>>> https://issues.apache.org/jira/browse/PDFBOX-2094 <
>>>>>> https://issues.apache.org/jira/browse/PDFBOX-2094>
>>>>>> 
>>>>>> — John
>>>>>> 
>>>>>>> On 7 May 2015, at 16:04, Gregor Kovač <[email protected]> wrote:
>>>>>>> 
>>>>>>> Hi!
>>>>>>> 
>>>>>>> I'm using PDFBox 1.8.9 and using this method to print a PDF file:
>>>>>>> 
>>>>>>> private static void printWithPDFBox(File pdfFile, int copies) {
>>>>>>> PDDocument document = null;
>>>>>>> 
>>>>>>> try {
>>>>>>>     document = PDDocument.load(pdfFile);
>>>>>>> 
>>>>>>>     PrintService printService =
>>>>>>> PrintServiceLookup.lookupDefaultPrintService();
>>>>>>>     PrinterJob printJob = PrinterJob.getPrinterJob();
>>>>>>>     printJob.setJobName(pdfFile.getName());
>>>>>>>     printJob.setPrintService(printService);
>>>>>>>     printJob.setCopies(copies);
>>>>>>> 
>>>>>>>     HashPrintRequestAttributeSet printRequestAttributeSet = new
>>>>>>> HashPrintRequestAttributeSet();
>>>>>>>     printRequestAttributeSet.add(new Copies(copies));
>>>>>>>     printRequestAttributeSet.add(SheetCollate.COLLATED);
>>>>>>>     printJob.setPageable(new PDPageable(document, printJob));
>>>>>>>     printJob.print(printRequestAttributeSet);
>>>>>>> } catch (Exception e) {
>>>>>>>     e.printStackTrace();
>>>>>>> } finally {
>>>>>>>     if (document != null) {
>>>>>>>         try {
>>>>>>>             document.close();
>>>>>>>         } catch (IOException e) {
>>>>>>>             e.printStackTrace();
>>>>>>>         }
>>>>>>>     }
>>>>>>> }
>>>>>>> }
>>>>>>> 
>>>>>>> 
>>>>>>> I have a test file with one page and when I call this method with
>>>> copies
>>>>>>> greater than 1 I only get one page printed out.
>>>>>>> 
>>>>>>> Am I doing something wrong?
>>>>>>> 
>>>>>>> Best regards,
>>>>>>> Kovi
>>>>>>> 
>>>>>>> --
>>>>>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>>>>>>> |  In A World Without Fences Who Needs Gates?  |
>>>>>>> |              Experience Linux.               |
>>>>>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>>>>> |  In A World Without Fences Who Needs Gates?  |
>>>>> |              Experience Linux.               |
>>>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>>> |  In A World Without Fences Who Needs Gates?  |
>>> |              Experience Linux.               |
>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>> 
>> 
> 
> 
> -- 
> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> |  In A World Without Fences Who Needs Gates?  |
> |              Experience Linux.               |
> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Reply via email to