You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Christophe Borivant (JIRA)" <ji...@apache.org> on 2012/07/05 18:03:35 UTC

[jira] [Updated] (PDFBOX-974) PrintPDF should not be case sensitive against printer name on Windows

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

Christophe Borivant updated PDFBOX-974:
---------------------------------------

       Priority: Major  (was: Minor)
    Description: 
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 :

                      if(printService[i].getName().indexOf(printerName) != -1)
                      {
                          printJob.setPrintService(printService[i]);
                          printerFound = true;
                      }
to :
                    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;
                      }
                    }
and added the method :
    public static boolean isWindows()
    {
        String os = System.getProperty("os.name").toLowerCase();
        return (os.indexOf( "win" ) >= 0);
    }

I'm not sure it's the best way to do it, but at least, it works !


  was:
Microsoft Os are mostly non case sensitive.
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 :

                      if(printService[i].getName().indexOf(printerName) != -1)
                      {
                          printJob.setPrintService(printService[i]);
                          printerFound = true;
                      }
to :
                    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;
                      }
                    }
and added the method :
    public static boolean isWindows()
    {
        String os = System.getProperty("os.name").toLowerCase();
        return (os.indexOf( "win" ) >= 0);
    }

I'm not sure it's the best way to do it, but at least, it works !


    
> 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
>
> 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 :
>                       if(printService[i].getName().indexOf(printerName) != -1)
>                       {
>                           printJob.setPrintService(printService[i]);
>                           printerFound = true;
>                       }
> to :
>                     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;
>                       }
>                     }
> and added the method :
>     public static boolean isWindows()
>     {
>         String os = System.getProperty("os.name").toLowerCase();
>         return (os.indexOf( "win" ) >= 0);
>     }
> I'm not sure it's the best way to do it, but at least, it works !

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira