pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Flattening (?) Problem 2.0.5->2.0.11
Date Fri, 01 Feb 2019 17:57:16 GMT
Am 01.02.2019 um 14:50 schrieb Aaron Mulder:
> Historically, I haven't been able to print from within Java because I
> must be able to turn duplex on and off and specify a source paper tray
> (one has paper, one has labels, and different jobs go to each).  I
> never got that to work except via lpr.  Though, it's probably been a
> couple years since I tried because the current system works.  :)


Duplex is like this:


             PrinterJob job = PrinterJob.getPrinterJob();
             job.setPageable(new PDFPageable(document));
             PrintRequestAttributeSet pras = new 
HashPrintRequestAttributeSet();
             pras.add(Sides.TWO_SIDED_LONG_EDGE);

             if (job.printDialog(pras))
             {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                 try
                 {
                     job.print(pras);
                 }
                 finally
                 {
                     setCursor(Cursor.getDefaultCursor());
                 }
             }

tray is more tricky, see e.g.

https://stackoverflow.com/questions/14328012/printing-with-attributestray-control-duplex-etc-using-javax-print-library

Tilman


>
> I'll try the snapshot and code change when I get a chance.
>
> Thanks,
>         Aaron
>
> On Thu, Jan 31, 2019 at 12:17 AM Tilman Hausherr <THausherr@t-online.de> wrote:
>> Hi,
>> The current version is 2.0.13. Did you try with that one? Also try with
>> a 2.0.14 snapshot
>> https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.14-SNAPSHOT/
>>
>> and please share the source file, and modify the code so that the fifth
>> parameter of
>>
>> PDPageContentStream() is true.
>>
>> Consider printing from PDFBox itself.
>>
>> Tilman
>>
>> Am 31.01.2019 um 02:52 schrieb Aaron Mulder:
>>> I have a PDF workflow where I take a base document with forms, then
>>> append a footer that puts values in the form fields and save the
>>> result, then open it with PDFBox and flatten it:
>>>
>>> doc = PDDocument.load(tempFile);
>>> doc.getDocumentCatalog().getAcroForm().flatten();
>>>
>>> Then I add an image to the page and save and close the doc:
>>>
>>> PDPage page = doc.getPage(0);
>>> PDImageXObject image = LosslessFactory.createFromImage(doc,
>>> toBufferedImage(generateBarcode("PC"+pcId)));
>>> PDPageContentStream contentStream = new PDPageContentStream(doc, page,
>>> PDPageContentStream.AppendMode.APPEND, true);
>>> contentStream.drawImage(image, 246, 36 );
>>> contentStream.close();
>>> doc.save(tempFile);
>>> doc.close();
>>>
>>> Finally, I print it from the command line.  With PDFBox 2.0.5 the
>>> resulting document prints fine.  I'm using this command on macOS:
>>>
>>> /usr/bin/lpr -P TestPrinter -o InputSlot=Tray2 file.pdf
>>>
>>> With PDFBox 2.0.11 when I do the same, the form fields all come
>>> through as empty on the printout.  (They do appear when I open the doc
>>> in Preview.)
>>>
>>> I don't really know why; I just tried updating to the latest on a
>>> lark.  It feels like the flattening failed on 2.0.11.  The printer is
>>> a bit dated and I think I went with flattening in the first place
>>> because that was the only way to get the doc to print correctly from
>>> the command line.
>>>
>>> I will stick with 2.0.5 for now because for this case it's critical
>>> that the printouts work.  :)
>>>
>>> Thanks,
>>>         Aaron
>>>
>>> Output from 2.0.5: http://opentools.org/files/print-job-2514255277731407198.pdf
>>> Output from 2.0.11: http://opentools.org/files/print-job-4933385101348305078.pdf
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message