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: Printing Sides and Chromaticity
Date Mon, 29 Jan 2018 17:01:49 GMT
I haven't understood the first part of your question but here's a 
segment in PDFDebugger, maybe that can answer it somewhat:

             PrinterJob job = PrinterJob.getPrinterJob();
             job.setPageable(new PDFPageable(document));
             PrintRequestAttributeSet pras = new 
HashPrintRequestAttributeSet();
             PDViewerPreferences vp = 
document.getDocumentCatalog().getViewerPreferences();
             if (vp != null && vp.getDuplex() != null)
             {
                 String dp = vp.getDuplex();
                 if 
(PDViewerPreferences.DUPLEX.DuplexFlipLongEdge.toString().equals(dp))
                 {
                     pras.add(Sides.TWO_SIDED_LONG_EDGE);
                 }
                 else if 
(PDViewerPreferences.DUPLEX.DuplexFlipShortEdge.toString().equals(dp))
                 {
                     pras.add(Sides.TWO_SIDED_SHORT_EDGE);
                 }
                 else if 
(PDViewerPreferences.DUPLEX.Simplex.toString().equals(dp))
                 {
                     pras.add(Sides.ONE_SIDED);
                 }
             }
             if (job.printDialog(pras))
             {
                 job.print(pras);
             }

To set it, just call document.getDocumentCatalog().setViewerPreferences().

Re grayscale:
there is no feature to change a PDF to grey. You could render a PDF to a 
greyscale image and then print that one.

Tilman


Am 28.01.2018 um 22:39 schrieb Ivan Ridao Freitas | IvanRF.com:
> Hi, I have two question regarding Java Printing attributes.
>
> *Sides*: a new HP printer has Duplex mode as default an encountered 
> two different outputs for these scenarios:
>
>  - a PDDocument with one page, but setting PrinterJob.setCopies(2): 
> prints ok one page after the other
>
>  - a PDDocument with two equal pages in it (without using setCopies): 
> prints one page and the printer stops showing a message to continue 
> with Duplex mode. (this can only be solved by always adding 
> Sides.ONE_SIDED and print with attributes)
>
> My question is, can the side behaviour be set on the PDDocument or the 
> only way to always use "one sided" is with attributes?
> I saw in the Printing example 
> <https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/Printing.java>

> a conversion from PDViewerPreferences.DUPLEX.Simplex to 
> Sides.ONE_SIDED, but I don't know how to use PDViewerPreferences and 
> more importantly if these preferences are actually respected when 
> printing.
>
> *
> Chromaticity*: similar to this question 
> <http://markmail.org/message/5sr6p2d36xpm32eq>, the same HP printer 
> always prints in color, ignoring the attribute 
> Chromaticity.MONOCHROME. I tested a virtual printer (with Snagit) and 
> that attribute works. So, I can assume that the printer is the one 
> discarding the Chromaticity attribute.
>
> My question is, PDFBox provides a way to change a PDF to grayscale? If 
> not, could you indicate me at which point should be the color 
> conversion be made?
>
> I'm using the latest PDFBox 2.0.8.
>
> Thanks,
> Ivan
>
>


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


Mime
View raw message