[ 
https://issues.apache.org/jira/browse/PDFBOX-3453?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tres Finocchiaro updated PDFBOX-3453:
-------------------------------------
    Description: 
On MacOS, when supplying custom attributes to the print interface, it has the 
reverse effect and ignores the attributes specified, including the page size.

In the below example, the page size will default to US Letter (8.5 x 11) 
despite being specified as 4 x 6.

A temporary workaround is to not specify any PrintRequestAttributes, downside 
being you lose the option for collation, copies, chromacity, print tray, etc.

 * This bug is NOT reproducible on Windows.
 * This bug is NOT reproducible on Mac when using a non-PDFBOX library to print.
 * This bug only occurs when using PDFBOX and MacOS and custom print attributes 
are supplied to the print job.

{code}
    public static void main(String[] args) throws Exception {
        //test data
        Paper paper = new Paper();
        paper.setSize(4 * 72, 6 * 72); //4x6in
        paper.setImageableArea(0, 0, 4 * 72, 6 * 72);

        PageFormat pf = new PageFormat();
        pf.setPaper(paper);

        PDDocument doc = PDDocument.load(new File(args[0]));
        Book book = new Book();
        book.append(new PDFPrintable(doc, Scaling.SCALE_TO_FIT, false, 0, 
false), pf);


        //No print attributes - Works
        PrinterJob jobPlain = PrinterJob.getPrinterJob();
        jobPlain.setPageable(book);
        jobPlain.print();

        //With print attributes - Fails, resets paper size to system default & 
attributes are ignored
        PrintRequestAttributeSet attributes = new 
HashPrintRequestAttributeSet();
        attributes.add(Chromaticity.MONOCHROME);

        PrinterJob jobAttr = PrinterJob.getPrinterJob();
        jobAttr.setPageable(book);
        jobAttr.print(attributes);
    }
{code}

  was:
On MacOS, when supplying custom attributes to the print interface, it has the 
reverse effect and ignores the attributes specified, including the page size.

In the below example, the page size will default to US Letter (8.5 x 11) 
despite being specified as 4 x 6.

A temporary workaround is to not specify any PrintRequestAttributes, downside 
being you lose the option for collation, copies, chromacity, print tray, etc.

 * This bug is NOT reproducible on Windows.
 * This bug is NOT reproducible when using a non-PDFBOX library to print.

{code}
    public static void main(String[] args) throws Exception {
        //test data
        Paper paper = new Paper();
        paper.setSize(4 * 72, 6 * 72); //4x6in
        paper.setImageableArea(0, 0, 4 * 72, 6 * 72);

        PageFormat pf = new PageFormat();
        pf.setPaper(paper);

        PDDocument doc = PDDocument.load(new File(args[0]));
        Book book = new Book();
        book.append(new PDFPrintable(doc, Scaling.SCALE_TO_FIT, false, 0, 
false), pf);


        //No print attributes - Works
        PrinterJob jobPlain = PrinterJob.getPrinterJob();
        jobPlain.setPageable(book);
        jobPlain.print();

        //With print attributes - Fails, resets paper size to system default & 
attributes are ignored
        PrintRequestAttributeSet attributes = new 
HashPrintRequestAttributeSet();
        attributes.add(Chromaticity.MONOCHROME);

        PrinterJob jobAttr = PrinterJob.getPrinterJob();
        jobAttr.setPageable(book);
        jobAttr.print(attributes);
    }
{code}


> PDFPrintable plus PrintRequestAttributeSet breaks page size
> -----------------------------------------------------------
>
>                 Key: PDFBOX-3453
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3453
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>         Environment: Java 8 u77, MacOS 10.11
>            Reporter: Tres Finocchiaro
>            Priority: Critical
>
> On MacOS, when supplying custom attributes to the print interface, it has the 
> reverse effect and ignores the attributes specified, including the page size.
> In the below example, the page size will default to US Letter (8.5 x 11) 
> despite being specified as 4 x 6.
> A temporary workaround is to not specify any PrintRequestAttributes, downside 
> being you lose the option for collation, copies, chromacity, print tray, etc.
>  * This bug is NOT reproducible on Windows.
>  * This bug is NOT reproducible on Mac when using a non-PDFBOX library to 
> print.
>  * This bug only occurs when using PDFBOX and MacOS and custom print 
> attributes are supplied to the print job.
> {code}
>     public static void main(String[] args) throws Exception {
>         //test data
>         Paper paper = new Paper();
>         paper.setSize(4 * 72, 6 * 72); //4x6in
>         paper.setImageableArea(0, 0, 4 * 72, 6 * 72);
>         PageFormat pf = new PageFormat();
>         pf.setPaper(paper);
>         PDDocument doc = PDDocument.load(new File(args[0]));
>         Book book = new Book();
>         book.append(new PDFPrintable(doc, Scaling.SCALE_TO_FIT, false, 0, 
> false), pf);
>         //No print attributes - Works
>         PrinterJob jobPlain = PrinterJob.getPrinterJob();
>         jobPlain.setPageable(book);
>         jobPlain.print();
>         //With print attributes - Fails, resets paper size to system default 
> & attributes are ignored
>         PrintRequestAttributeSet attributes = new 
> HashPrintRequestAttributeSet();
>         attributes.add(Chromaticity.MONOCHROME);
>         PrinterJob jobAttr = PrinterJob.getPrinterJob();
>         jobAttr.setPageable(book);
>         jobAttr.print(attributes);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to