Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 857D7189EC for ; Wed, 13 May 2015 08:44:15 +0000 (UTC) Received: (qmail 11438 invoked by uid 500); 13 May 2015 08:44:15 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 11411 invoked by uid 500); 13 May 2015 08:44:15 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 11395 invoked by uid 99); 13 May 2015 08:44:14 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2015 08:44:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 68489C1393 for ; Wed, 13 May 2015 08:44:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.88 X-Spam-Level: ** X-Spam-Status: No, score=2.88 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id w9J28C7C9UQ2 for ; Wed, 13 May 2015 08:44:09 +0000 (UTC) Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 270DE230A4 for ; Wed, 13 May 2015 08:44:09 +0000 (UTC) Received: by oiko83 with SMTP id o83so25877332oik.1 for ; Wed, 13 May 2015 01:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=U5q666NqBIQJxdpgf1mK9n00ndknsb1qJrKcJebqtn8=; b=svDF9BshafuiGuUVyUeUPqXNIJBe6cqR88o2hFEL3dfGqYqqL60+75G6W+CiKHaBdj qOZr9QcBvViRc0tGwwh5SLqpLKaa07xvf7iLUVh9K9u5d2sLVHRtNKPSMtLrcxiOCog8 sMmLOmO94+TPS+U+y86lvBwe9XBMBnVhG1yOKm6+UcZverVlLNzC1tHOD0MQ8KSE66By HSq+7/nKC+ORdf8ThPq221YgjrAt8/kcyTAiYYJe0iSrAgcoAZeIKtDAyA+g1IJEYkeD LwB3/1/HYbORH95MB9QAK8dEEiFY0FNI4kvCpHMTZ2Jyzl8LsXePjecW/ixQqnlMIzpQ sxpw== MIME-Version: 1.0 X-Received: by 10.60.82.4 with SMTP id e4mr15199828oey.42.1431506648323; Wed, 13 May 2015 01:44:08 -0700 (PDT) Received: by 10.202.44.85 with HTTP; Wed, 13 May 2015 01:44:08 -0700 (PDT) In-Reply-To: <72904FBD-D051-47CF-B452-22FC5A972EB5@jahewson.com> References: <959D3937-782C-419F-8E8E-B37DD4184432@jahewson.com> <02529D9E-21CB-4431-BD4A-BC9968BE5BCB@jahewson.com> <72904FBD-D051-47CF-B452-22FC5A972EB5@jahewson.com> Date: Wed, 13 May 2015 10:44:08 +0200 Message-ID: Subject: Re: PDF Printing: multiple copies From: =?UTF-8?Q?Gregor_Kova=C4=8D?= To: users@pdfbox.apache.org Content-Type: multipart/alternative; boundary=047d7b6767d64465350515f29df8 --047d7b6767d64465350515f29df8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 : > > > On 12 May 2015, at 13:17, Gregor Kova=C4=8D wrote: > > > > Hi! > > > > Hmm... How? Can you share the code you are using? > > I just copied and pasted the code from your e-mail. > > =E2=80=94 John > > P.S. just in case, make sure that you=E2=80=99ve run: > > svn up > mvn clean install > > > Best regards, > > Kovi > > > > 2015-05-12 19:39 GMT+02:00 John Hewson : > > > >> That=E2=80=99s a shame, I can confirm that it works for me on OS X wit= h Sun=E2=80=99s > JDK. > >> > >> =E2=80=94 John > >> > >>> On 12 May 2015, at 06:58, Gregor Kova=C4=8D 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 : > >>> > >>>> So I took another look at this and I think there=E2=80=99s a bug in = PDFPrinter > >>>> where the > >>>> attributes are being discarded after showing the print dialog. > >>>> > >>>> I=E2=80=99ve made a commit in PDFBOX-2795 which hopefully fixes it, = you=E2=80=99ll > need > >> to > >>>> fetch the latest trunk via SVN. > >>>> > >>>> =E2=80=94 John > >>>> > >>>>> On 12 May 2015, at 00:13, Gregor Kova=C4=8D wrot= e: > >>>>> > >>>>> 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 : > >>>>> > >>>>>> Your code looks fine, I suspect that as you say, the problem is wi= th > >>>>>> Java=E2=80=99s interaction with your printer driver, especially as= you=E2=80=99re > >> having > >>>>>> the same problem with other libraries. > >>>>>> > >>>>>> =E2=80=94 John > >>>>>> > >>>>>>> On 8 May 2015, at 17:00, Gregor Kova=C4=8D wro= te: > >>>>>>> > >>>>>>> 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 =3D null; > >>>>>>> > >>>>>>> try { > >>>>>>> document =3D PDDocument.load(pdfFile); > >>>>>>> > >>>>>>> PrinterJob printJob =3D PrinterJob.getPrinterJob(); > >>>>>>> printJob.setJobName(pdfFile.getName()); > >>>>>>> > >>>>>>> > >>>> > >> > printJob.setPrintService(PrintServiceLookup.lookupDefaultPrintService()); > >>>>>>> > >>>>>>> printJob.setCopies(copies); > >>>>>>> HashPrintRequestAttributeSet printRequestAttributeSet =3D= new > >>>>>>> HashPrintRequestAttributeSet(); > >>>>>>> printRequestAttributeSet.add(new Copies(copies)); > >>>>>>> printRequestAttributeSet.add(SheetCollate.COLLATED); > >>>>>>> PDFPrinter printer =3D new PDFPrinter(document, > >>>>>>> Scaling.ACTUAL_SIZE, Orientation.AUTO); > >>>>>>> printer.print(printJob, printRequestAttributeSet); > >>>>>>> } catch (Exception e) { > >>>>>>> e.printStackTrace(); > >>>>>>> } finally { > >>>>>>> if (document !=3D 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 ou= t. > >>>>>>> > >>>>>>> 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 o= r > >>>>>>> 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=3DTrue example.pdf" I get a PDF with 5 pages, becu= ase > >>>>>>> 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 : > >>>>>>> > >>>>>>>> This has been fixed in 2.0: > >>>>>>>> > >>>>>>>> https://issues.apache.org/jira/browse/PDFBOX-2094 < > >>>>>>>> https://issues.apache.org/jira/browse/PDFBOX-2094> > >>>>>>>> > >>>>>>>> =E2=80=94 John > >>>>>>>> > >>>>>>>>> On 7 May 2015, at 16:04, Gregor Kova=C4=8D w= rote: > >>>>>>>>> > >>>>>>>>> Hi! > >>>>>>>>> > >>>>>>>>> I'm using PDFBox 1.8.9 and using this method to print a PDF fil= e: > >>>>>>>>> > >>>>>>>>> private static void printWithPDFBox(File pdfFile, int copies) { > >>>>>>>>> PDDocument document =3D null; > >>>>>>>>> > >>>>>>>>> try { > >>>>>>>>> document =3D PDDocument.load(pdfFile); > >>>>>>>>> > >>>>>>>>> PrintService printService =3D > >>>>>>>>> PrintServiceLookup.lookupDefaultPrintService(); > >>>>>>>>> PrinterJob printJob =3D PrinterJob.getPrinterJob(); > >>>>>>>>> printJob.setJobName(pdfFile.getName()); > >>>>>>>>> printJob.setPrintService(printService); > >>>>>>>>> printJob.setCopies(copies); > >>>>>>>>> > >>>>>>>>> HashPrintRequestAttributeSet printRequestAttributeSet =3D ne= w > >>>>>>>>> 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 !=3D null) { > >>>>>>>>> try { > >>>>>>>>> document.close(); > >>>>>>>>> } catch (IOException e) { > >>>>>>>>> e.printStackTrace(); > >>>>>>>>> } > >>>>>>>>> } > >>>>>>>>> } > >>>>>>>>> } > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> I have a test file with one page and when I call this method wi= th > >>>>>> 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 > > --=20 -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ | In A World Without Fences Who Needs Gates? | | Experience Linux. | -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ --047d7b6767d64465350515f29df8--