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

Tilman Hausherr resolved PDFBOX-974.
------------------------------------
    Fix Version/s: 2.0.34
                   3.0.5 PDFBox
                   4.0.0
         Assignee: Tilman Hausherr
       Resolution: Fixed

I made it case insensitive for all. It's a command line utility so people may 
make mistakes.

> PrintPDF should not be case sensitive against printer name on Windows
> ---------------------------------------------------------------------
>
>                 Key: PDFBOX-974
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-974
>             Project: PDFBox
>          Issue Type: Wish
>          Components: Utilities
>    Affects Versions: 1.5.0
>         Environment: Windows XP/ JRE 1.6.0_24
>            Reporter: Christophe Borivant
>            Assignee: Tilman Hausherr
>            Priority: Minor
>             Fix For: 2.0.34, 3.0.5 PDFBox, 4.0.0
>
>
> Microsoft Os are mostly case insensitive.
> If a printerName is given to PrintPDF, it looks for the provided string in a 
> case sensitive manner ( line around 115 ).
> I made a little correction to the code to allow non case sensitive search on 
> Windows os :
> I changed :
> {code}
>                       if(printService[i].getName().indexOf(printerName) != -1)
>                       {
>                           printJob.setPrintService(printService[i]);
>                           printerFound = true;
>                       }
> {code}
> to :
> {code}
>                     if (isWindows())
>                     {
>                       
> if(printService[i].getName().toLowerCase().indexOf(printerName.toLowerCase()) 
> != -1)
>                       {
>                           printJob.setPrintService(printService[i]);
>                           printerFound = true;
>                       }
>                     }
>                     else
>                     {
>                       if(printService[i].getName().indexOf(printerName) != -1)
>                       {
>                           printJob.setPrintService(printService[i]);
>                           printerFound = true;
>                       }
>                     }
> {code}
> and added the method :
> {code}
>     public static boolean isWindows()
>     {
>         String os = System.getProperty("os.name").toLowerCase();
>         return (os.indexOf( "win" ) >= 0);
>     }
> {code}
> I'm not sure it's the best way to do it, but at least, it works !



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to