pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregor Kovač <kov...@gmail.com>
Subject Re: PDF Printing: multiple copies
Date Thu, 14 May 2015 12:06:44 GMT
Hi!

I'm just using "lpr -# 3 -oCollate=True example.pdf" on Linux.

Best regards,
    Kovi

2015-05-13 20:08 GMT+02:00 John Hewson <john@jahewson.com>:

> Ok, that pretty much confirms it as a Java on Linux issue. Try using a
> newer JDK, or using Sun’s JDK.
>
> There are also some platform-specific printing libraries for Java, such
> as http://cups4j.org <http://cups4j.org/> which might be worth a look? I
> have zero experience
> with these though.
>
> — John
>
> > On 13 May 2015, at 01:44, Gregor Kovač <kovica@gmail.com> wrote:
> >
> > Hi!
> >
> > I just found out that this code does work on Windows, but not on Linux.
> >
> > Best regards,
> >    Kovi
> >
> > 2015-05-13 0:23 GMT+02:00 John Hewson <john@jahewson.com>:
> >
> >>
> >>> On 12 May 2015, at 13:17, Gregor Kovač <kovica@gmail.com> wrote:
> >>>
> >>> Hi!
> >>>
> >>> Hmm... How? Can you share the code you are using?
> >>
> >> I just copied and pasted the code from your e-mail.
> >>
> >> — John
> >>
> >> P.S. just in case, make sure that you’ve run:
> >>
> >> svn up
> >> mvn clean install
> >>
> >>> Best regards,
> >>>   Kovi
> >>>
> >>> 2015-05-12 19:39 GMT+02:00 John Hewson <john@jahewson.com>:
> >>>
> >>>> 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č <kovica@gmail.com>
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 <john@jahewson.com>:
> >>>>>
> >>>>>> 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č <kovica@gmail.com>
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 <john@jahewson.com>:
> >>>>>>>
> >>>>>>>> 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č <kovica@gmail.com>
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 <john@jahewson.com>:
> >>>>>>>>>
> >>>>>>>>>> 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č <kovica@gmail.com>
> 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.               |
> >>>>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> >>> |  In A World Without Fences Who Needs Gates?  |
> >>> |              Experience Linux.               |
> >>> -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> >> For additional commands, e-mail: users-help@pdfbox.apache.org
> >>
> >>
> >
> >
> > --
> > -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> > |  In A World Without Fences Who Needs Gates?  |
> > |              Experience Linux.               |
> > -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
>
>


-- 
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
|  In A World Without Fences Who Needs Gates?  |
|              Experience Linux.               |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

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