[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] [9] RFR JDK-6574279: validatePage from PrinterJob returns argument under linux
From:       Prasanta Sadhukhan <prasanta.sadhukhan () oracle ! com>
Date:       2016-09-02 10:12:50
Message-ID: 57C94DD2.1050401 () oracle ! com
[Download RAW message or body]

We match the CUPS returned media to standard media here
http://hg.openjdk.java.net/jdk9/client/jdk/file/03c248ab7484/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java#l218


As per getPageSizes(), it returns the size of the media as 
mentioned(including margin) but the testcase actually sets imageablearea 
to (0,0,paperwidth,paperheight) which matches one of the many page size(s)
as I earlier mentioned, (0,0,8.26",11.69") is within supported mpa of a 
paper size 0,0,11.69",16.52" (which is one of the pagesize returned by 
getPageSizes()) so it means 0,0,8",11" comes out to be supported mpa
and so it was allowed (eventhough printer cannot print from 0,0)
so we should also take care of the printer-allowable (hardware) margin 
which in windows was taken care of by GetDeviceCaps(printDC, 
PHYSICALOFFSETX) function so I had to add getHWMargin() in linux here in 
this fix.

Modified webrev which passes JPRT is here
http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.04/

Regards
Prasanta
On 8/19/2016 3:56 AM, Philip Race wrote:
> PS as I just mentioned in another review thread, I have
> a suspicion that the Media and MPA for CUPS are never matched
> to "standard" (pre-defined in API) ones. I don't know how much this 
> matters - A4
> when sent to printing should (he says) get matched on size
> to the right media but you should check that, but this also
> may mean that if you try to get the MPA for the "standard" 
> MediaSizeName.ISO_A4
> none will be found .. all this sets back this fix until you work 
> through that
> but I don't think the fix can be completely right until we have an 
> understanding
> and resolution on that.
> 
> -phil.
> 
> On 8/17/16, 12:07 PM, Phil Race wrote:
> > The cups docs say you can get physical margins as described here : 
> > http://opensource.apple.com//source/cups/cups-62/doc/spm.shtml?txt#CUPS_API
> > ------------------------
> > PPD files specify all of the available pages sizes and the physical 
> > margins associated with them. ...
> > ppd_sizet_ size = ppdPageSize(ppd, "/size/"); ...
> > The|||ppd_size_t| structure contains the width, length, and margin 
> > information:
> > 
> > typedef struct    /**** Page Sizes ****/
> > {
> > int   marked;   /* Page size selected? */
> > char  name[41]; /* Media size option */
> > float width,    /* Width of media in points */
> > length,   /* Length of media in points */
> > left,     /* Left printable margin in points */
> > bottom,   /* Bottom printable margin in points */
> > right,    /* Right printable margin in points */
> > top;      /* Top printable margin in points */
> > } ppd_size_t;
> > 
> > 
> > --------------------
> > 
> > Moreover we are *already* calling that code : See 
> > Java_sun_print_CUPSPrinter_getPageSizes Does that not work ? Perhaps 
> > the gap is that CUPSPrinter.java does not tie the MPA to the Media it 
> > has created. Not sure of the best way to do this. Maybe the windows 
> > code solves this differently but a simple HashMap may work here. 
> > You'll have to investigate. A few specific comments on the code :- 
> > 484 if (option != NULL && option->num_choices > 0) { we are expecting 
> > an array of 4 elements here so may be >=4 is what we should require ? 
> > 500 JNU_ThrowOutOfMemoryError(env, "Could not create printer name"); 
> > comment seems to be a copy from an earlier line .. this is about 
> > allocating an array  516     @Override  517     protected void 
> > validatePaper(Paper origPaper, Paper newPaper) {  518         if 
> > (!(getPrintService() instanceof IPPPrintService)) {  519             
> > super.validatePaper(origPaper, newPaper);  520             return; 
> > Hmm.  IPPPrintService is Unix only whereas PSPrinterJob is shared 
> > code .. so I will bet you didn't try yet to compile this on Windows. 
> > -phil. On 8/16/16, 4:47 AM, Prasanta Sadhukhan wrote:
> > > Hi All,
> > > On 8/11/2016 2:08 PM, Prasanta Sadhukhan wrote:
> > > > Hi Phil,
> > > > On 8/11/2016 3:05 AM, Phil Race wrote:
> > > > > There does not seem to be a link to the new webrev in here. Is it 
> > > > > this : http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.01/ ? 
> > > > > > to default Paper (Letter in US, A4 otherwise) imageable area I 
> > > > > don't think that will ever be A4. Where is that coming from ? And 
> > > > > you still have not fixed the problem with how you retrieve the MPA 
> > > > > > -  512             MediaPrintableArea mpa = (MediaPrintableArea) 
> > > > > 513 
> > > > > getPrintService().getDefaultAttributeValue(MediaPrintableArea.class); 
> > > > > It is not supposed to be the MPA of the *default* paper. You want 
> > > > > the MPA of *this* paper. Only if origPaper is not a supported 
> > > > > paper do you go look for the default paper.
> > > > As you suggested, I have modified to check if mpa of origPaper is 
> > > > amongst supported mpa(s) of the printer, if not, then go for mpa of 
> > > > default paper. However, it seems among 61 mpas returned by 
> > > > CUPSPrinter , origPaper of 0,0,8.26",11.69" is within supported mpa 
> > > > of a paper size 0,0,11.69",16.52" so it means 0,0,8",11" comes out 
> > > > to be supported mpa. Can you please comment on this modified webrev 
> > > > on what more we can do? 
> > > > http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.02/ I guess 
> > > > we need to find out the physical limitation of printer via CUPS 
> > > > same what we do in windows via GetDeviceCaps(printDC, 
> > > > PHYSICALOFFSETX); and use that in calculation for valid margin but 
> > > > I could not find equivalent cups function. Can you suggest anyways? 
> > > I tried calling ppdFindOption(ppd, "HWMargins") in CUPS but it 
> > > returns null although my printer ppd file has this line *%=== Custom 
> > > Paper Support ================= *LeadingEdge Short: "" *LeadingEdge 
> > > Long: "" *DefaultLeadingEdge: Short *MaxMediaWidth:  "865" 
> > > *MaxMediaHeight: "1701" **HWMargins:      12 12 12 12 *Anyways, I 
> > > have updated the webrev to take care of the review comments and also 
> > > get HWMargin (if the above ppdFindOption return null then fall back 
> > > to custom margin as reported via ppd_file_t structure 
> > > https://www.cups.org/doc/api-ppd.html#ppd_file_s) 
> > > http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.03/ Please 
> > > review. Tested in ubuntu and solaris11. Regards Prasanta
> > > > Regards Prasanta
> > > > > -phil. On 08/05/2016 03:20 AM, Prasanta Sadhukhan wrote:
> > > > > > On 8/4/2016 5:45 PM, Prasanta Sadhukhan wrote:
> > > > > > > I will override in PSPrinterJob but 1662             
> > > > > > > MediaPrintableArea mpa = 1663 
> > > > > > > (MediaPrintableArea)getPrintService(). 1664 
> > > > > > > getDefaultAttributeValue(MediaPrintableArea.class); is returning 
> > > > > > > imageable area of default media of chosen printer from CUPS [ 
> > > > > > > all supported media printable area is obtained from 
> > > > > > > CUPSPrinter#getPageSizes(printer) & then initMedia() populates 
> > > > > > > cupsMediaPrintables which is returned in 
> > > > > > > getMediaPrintableArea()] as 
> > > > > > > IPPPrintService#getDefaultAttributeValue() does ---------- if 
> > > > > > > (category == MediaPrintableArea.class) {             
> > > > > > > MediaPrintableArea[] mpas;              if ((cps != null)  && 
> > > > > > > ((mpas = *cps.getMediaPrintableArea()*) != 
> > > > > > > null)) {                  if (defaultMediaIndex == -1) { 
> > > > > > > // initializes value of defaultMediaIndex 
> > > > > > > getDefaultAttributeValue(Media.class);                  } 
> > > > > > > return mpas[*defaultMediaIndex*];              
> > > > > > > } -------------- by which mpas[defaultMediaIndex] returns 
> > > > > > > default media printable area. In else block, we instantiate mpa 
> > > > > > > of Letter for US locale and A4 for other locales so I was not 
> > > > > > > checking for null as in both if and else block , I was getting 
> > > > > > > MediaPrintableArea instance. Regarding considering equal 
> > > > > > > margins, I am not sure if there was any way I could get right 
> > > > > > > and left margin separately. Please let me know if there is any 
> > > > > > > way you know of. 
> > > > > > I have modified to do the change in PSPrinterJob. Regarding the 
> > > > > > equal margin, we do the same in 
> > > > > > http://hg.openjdk.java.net/jdk9/client/jdk/file/abb2a39948fe/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#l688 \
> > > > > >  http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.01/ 
> > > > > That does not seem to be the same case as this. -phil.
> > > > > > Regards Prasanta
> > > > > > > Regards Prasanta
> > > > > > > On 8/4/2016 2:32 AM, Philip Race wrote:
> > > > > > > > High-level question. Why is this not an over-ride in 
> > > > > > > > PSPrinterJob ? I'm afraid I did not get much past the first 
> > > > > > > > line of the change : 1662             MediaPrintableArea mpa = 
> > > > > > > > 1663 (MediaPrintableArea)getPrintService(). 1664 
> > > > > > > > getDefaultAttributeValue(MediaPrintableArea.class); Read the 
> > > > > > > > docs for MediaPrintableArea :- --- To query for the printable 
> > > > > > > > area, a client must supply a suitable context. Without 
> > > > > > > > specifying at the very least the size of the media being used 
> > > > > > > > no meaningful value for printable area can be obtained. --- .. 
> > > > > > > > not to mention you assume a non-null return. and then you use 
> > > > > > > > new Paper() .. which is a constructor which knows nothing about 
> > > > > > > > the printer. It is *speced* to return US letter with one inch 
> > > > > > > > margins. Another reason why this seems like it should be a 
> > > > > > > > sub-class over-ride. Also this looks wrong --- 1672             
> > > > > > > > if ((imgX*2) + imgWid > wid) { 1673                 imgWid = 
> > > > > > > > wid - imgX*2; 1674             } You can't assume equal 
> > > > > > > > margins. -phil. On 7/12/16, 5:05 AM, Prasanta Sadhukhan wrote:
> > > > > > > > > Hi All, Please review a fix for an issue where it is seen that 
> > > > > > > > > if user sets invalid imageablearea via Paper.setImageableArea 
> > > > > > > > > and then calls PrinterJob.validatePage() in linux, then it 
> > > > > > > > > does not get a valid pageformat Bug: 
> > > > > > > > > https://bugs.openjdk.java.net/browse/JDK-6574279 webrev: 
> > > > > > > > > http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.00/ Fix 
> > > > > > > > > is to check for margin as noted via CUPS ppdPageSize() and 
> > > > > > > > > then calculate to find the valid margin in validatePaper() 
> > > > > > > > > similar to what we do in native validatePaper() in windows. 
> > > > > > > > > Regards Prasanta 


[Attachment #3 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    We match the CUPS returned media to standard media here <br>
<a class="moz-txt-link-freetext" \
href="http://hg.openjdk.java.net/jdk9/client/jdk/file/03c248ab7484/src/java.desktop/un \
ix/classes/sun/print/CUPSPrinter.java#l218">http://hg.openjdk.java.net/jdk9/client/jdk \
/file/03c248ab7484/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java#l218</a><br>
  <br>
    As per getPageSizes(), it returns the size of the media as
    mentioned(including margin) but the testcase actually sets
    imageablearea to (0,0,paperwidth,paperheight) which matches one of
    the many page size(s)<br>
    as I earlier mentioned, (0,0,8.26",11.69") is within supported mpa
    of a paper size 0,0,11.69",16.52" (which is one of the pagesize
    returned by getPageSizes()) so it means 0,0,8",11" comes out to be
    supported mpa<br>
    and so it was allowed (eventhough printer cannot print from 0,0)<br>
    so we should also take care of the printer-allowable (hardware)
    margin which in windows was taken care of by GetDeviceCaps(printDC,
    PHYSICALOFFSETX) function so I had to add getHWMargin() in linux
    here in this fix.<br>
    <br>
    Modified webrev which passes JPRT is here<br>
    <a class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.04/">http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.04/</a><br>
  <br>
    Regards<br>
    Prasanta<br>
    <div class="moz-cite-prefix">On 8/19/2016 3:56 AM, Philip Race
      wrote:<br>
    </div>
    <blockquote cite="mid:57B63633.8070004@oracle.com" type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      PS as I just mentioned in another review thread, I have<br>
      a suspicion that the Media and MPA for CUPS are never matched<br>
      to "standard" (pre-defined in API) ones. I don't know how much
      this matters - A4<br>
      when sent to printing should (he says) get matched on size <br>
      to the right media but you should check that, but this also<br>
      may mean that if you try to get the MPA for the "standard"
      MediaSizeName.ISO_A4<br>
      none will be found .. all this sets back this fix until you work
      through that<br>
      but I don't think the fix can be completely right until we have an
      understanding<br>
      and resolution on that.<br>
      <br>
      -phil.<br>
      <br>
      On 8/17/16, 12:07 PM, Phil Race wrote:
      <blockquote cite="mid:57B4B5D6.4030809@oracle.com" type="cite">
        <meta content="text/html; charset=utf-8"
          http-equiv="Content-Type">
        <meta http-equiv="content-type" content="text/html;
          charset=utf-8">
        <pre><meta http-equiv="content-type" content="text/html; charset=utf-8"><span \
class="new">The cups docs say you can get physical margins as described here :

</span><a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://opensource.apple.com//source/cups/cups-62/doc/spm.shtml?txt#CUPS_API">http://opensource.apple.com//source/cups/cups-62/doc/spm.shtml?txt#CUPS_API</a>
                
------------------------
<span class="new">PPD files specify all of the available pages sizes and the physical
margins associated with them. 
...
</span>
<span class="new">ppd_sizet_ size   = ppdPageSize(ppd, "<i>size</i>");
...
</span>
<span class="new">The<code> </code><code>ppd_size_t</code> structure contains the \
width, length, and margin information:

</span></pre>
      <ul>
        <pre>typedef struct    /**** Page Sizes ****/
{
  int   marked;   /* Page size selected? */
  char  name[41]; /* Media size option */
  float width,    /* Width of media in points */
        length,   /* Length of media in points */
        left,     /* Left printable margin in points */
        bottom,   /* Bottom printable margin in points */
        right,    /* Right printable margin in points */
        top;      /* Top printable margin in points */
} ppd_size_t;


--------------------
</pre>
      </ul>
      <pre><span class="new">
</span></pre>
      <span class="new">Moreover we are *already* calling that code :</span>

      <span class="new">See Java_sun_print_CUPSPrinter_getPageSizes</span>

      <span class="new"></span>

      <span class="new">Does that not work ?</span>

      Perhaps the gap is that CUPSPrinter.java does not tie the MPA to
      the Media

      it has created. Not sure of the best way to do this. Maybe the
      windows code

      solves this differently but a simple HashMap may work here. You'll
      have to

      investigate.

      <span class="new"></span>

      <span class="new">A few specific comments on the code :-</span>

      <span class="new"></span>

      <span class="new">

        484 if (option != NULL &amp;&amp; option-&gt;num_choices &gt; 0)
        { we are expecting an array of 4 elements here so may be &gt;=4
        is what we should require ? </span><span class="new"> 500
        JNU_ThrowOutOfMemoryError(env, "Could not create printer name");</span>

      comment seems to be a copy from an earlier line .. this is about

      allocating an array

      

        516         @Override

        517         protected void validatePaper(Paper origPaper, Paper
      newPaper) {     

        518                 if (!(getPrintService() instanceof IPPPrintService))
      {

        519                         super.validatePaper(origPaper, newPaper);

        520                         return;

      

      Hmm.   IPPPrintService is Unix only whereas PSPrinterJob is shared
      code .. 

      so I will bet you didn't try yet to compile this on Windows.

      

      

      -phil.

      

      On 8/16/16, 4:47 AM, Prasanta Sadhukhan wrote:
      <blockquote cite="mid:57B2FD59.2060106@oracle.com" type="cite">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        Hi All,

        

        <div class="moz-cite-prefix">On 8/11/2016 2:08 PM, Prasanta
          Sadhukhan wrote:

        </div>
        <blockquote cite="mid:57AC3983.7020504@oracle.com" type="cite">
          <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
          Hi Phil,

          

          <div class="moz-cite-prefix">On 8/11/2016 3:05 AM, Phil Race
            wrote:

          </div>
          <blockquote cite="mid:57AB9E3C.80302@oracle.com" type="cite">
            <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
            <div class="moz-cite-prefix">There does not seem to be a
              link to the new webrev in here.

              

              Is it this : <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/%7Epsadhukhan/6574279/webrev.01/">http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.01/</a>
  ?

              

              &gt; to default Paper (Letter in US, A4 otherwise)
              imageable area

              

              I don't think that will ever be A4. Where is that coming
              from ?

              

              And you still have not fixed the problem with how you
              retrieve the MPA :-

                512                         MediaPrintableArea mpa =
              (MediaPrintableArea)

                513                                        
              getPrintService().getDefaultAttributeValue(MediaPrintableArea.class);

              

              

              It is not supposed to be the MPA of the *default* paper.
              You want the MPA of *this* paper.

              Only if origPaper is not a supported paper do you go look
              for the default paper.

              

            </div>
          </blockquote>
          As you suggested, I have modified to check if mpa of origPaper
          is amongst supported mpa(s) of the printer, if not, then go
          for mpa of default paper. 

          However, it seems among 61 mpas returned by CUPSPrinter , 

          origPaper of 0,0,8.26",11.69" is within supported mpa of a
          paper size 0,0,11.69",16.52" so it means 0,0,8",11" comes out
          to be supported mpa.

          

          Can you please comment on this modified webrev on what more we
          can do?

          <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/%7Epsadhukhan/6574279/webrev.02/">http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.02/</a>


          

          I guess we need to find out the physical limitation of printer
          via CUPS same what we do in windows via  
          GetDeviceCaps(printDC, PHYSICALOFFSETX); and use that in
          calculation for valid margin

          but I could not find equivalent cups function. Can you suggest
          anyways?

          

        </blockquote>
        I tried calling ppdFindOption(ppd, "HWMargins") in CUPS but it
        returns null although my printer ppd file has this line

        

        *%=== Custom Paper Support =================

        *LeadingEdge Short: ""

        *LeadingEdge Long: ""

        *DefaultLeadingEdge: Short

        

        *MaxMediaWidth:   "865"

        *MaxMediaHeight: "1701"

        <b>*HWMargins:           12 12 12 12

          

        </b>Anyways, I have updated the webrev to take care of the
        review comments and also get HWMargin (if the above
        ppdFindOption return null then fall back to custom margin as
        reported via ppd_file_t structure 

        <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="https://www.cups.org/doc/api-ppd.html#ppd_file_s">https://www.cups.org/doc/api-ppd.html#ppd_file_s</a>)


        

        <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/%7Epsadhukhan/6574279/webrev.03/">http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.03/</a>


        

        Please review. Tested in ubuntu and solaris11.

        

        Regards

        Prasanta

        <blockquote cite="mid:57AC3983.7020504@oracle.com" type="cite">
          Regards

          Prasanta

          <blockquote cite="mid:57AB9E3C.80302@oracle.com" type="cite">
            <div class="moz-cite-prefix"> -phil.

              

              On 08/05/2016 03:20 AM, Prasanta Sadhukhan wrote:

            </div>
            <blockquote cite="mid:57A46852.4050801@oracle.com" type="cite">
              <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
              

              

              <div class="moz-cite-prefix">On 8/4/2016 5:45 PM, Prasanta
                Sadhukhan wrote:

              </div>
              <blockquote cite="mid:57A331E4.8000907@oracle.com" type="cite">
                <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
                I will override in PSPrinterJob but 

                1662                         MediaPrintableArea mpa = 

                1663                                                
                (MediaPrintableArea)getPrintService(). 

                1664                                                                
                getDefaultAttributeValue(MediaPrintableArea.class); 

                

                is returning imageable area of default media of chosen
                printer from CUPS [ all supported media printable area
                is obtained from CUPSPrinter#getPageSizes(printer) &amp;
                then initMedia() populates cupsMediaPrintables which is
                returned in getMediaPrintableArea()]

                as IPPPrintService#getDefaultAttributeValue() does

                ----------

                if (category == MediaPrintableArea.class) {

                                       MediaPrintableArea[] mpas;

                                         if ((cps != null)   &amp;&amp;

                                                 ((mpas = \
                <b>cps.getMediaPrintableArea()</b>)
                != null)) {

                                                 if (defaultMediaIndex == -1) {

                                                         // initializes value of
                defaultMediaIndex

                                                        
                getDefaultAttributeValue(Media.class);

                                                 }

                                                 return \
mpas[<b>defaultMediaIndex</b>];

                                         } 

                --------------

                by which mpas[defaultMediaIndex] returns default media
                printable area. 

                In else block, we instantiate mpa of Letter for US
                locale and A4 for other locales so I was not checking
                for null as in both if and else block , I was getting
                MediaPrintableArea instance.

                

                Regarding considering equal margins, I am not sure if
                there was any way I could get right and left margin
                separately.

                Please let me know if there is any way you know of.

              </blockquote>
              I have modified to do the change in PSPrinterJob.
              Regarding the equal margin, we do the same in <a moz-do-not-send="true" \
class="moz-txt-link-freetext" \
href="http://hg.openjdk.java.net/jdk9/client/jdk/file/abb2a39948fe/src/java.desktop/sh \
are/classes/sun/print/RasterPrinterJob.java#l688">http://hg.openjdk.java.net/jdk9/clie \
nt/jdk/file/abb2a39948fe/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#l688</a>


              <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/%7Epsadhukhan/6574279/webrev.01/">http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.01/</a>


            </blockquote>
            

            That does not seem to be the same case as this.

            

            -phil.

            

            <blockquote cite="mid:57A46852.4050801@oracle.com" type="cite"> 

              Regards

              Prasanta

              <blockquote cite="mid:57A331E4.8000907@oracle.com" type="cite"> 

                Regards

                Prasanta

                <div class="moz-cite-prefix">On 8/4/2016 2:32 AM, Philip
                  Race wrote:

                </div>
                <blockquote cite="mid:57A25BE6.3080305@oracle.com" \
type="cite">High-level question. Why is this not an  over-ride in PSPrinterJob ? 

                  

                  

                  I'm afraid I did not get much past the first line of
                  the change : 

                  1662                         MediaPrintableArea mpa = 

                  1663                                                
                  (MediaPrintableArea)getPrintService(). 

                  1664                                                                \
  getDefaultAttributeValue(MediaPrintableArea.class); 

                  

                  Read the docs for MediaPrintableArea :- 

                  --- 

                  To query for the printable area, a client must supply
                  a suitable context. 

                  Without specifying at the very least the size of the
                  media being used 

                  no meaningful value for printable area can be
                  obtained. 

                  --- 

                  

                  .. not to mention you assume a non-null return. 

                  

                  and then you use new Paper() .. which is a constructor
                  which 

                  knows nothing about the printer. It is *speced* to
                  return 

                  US letter with one inch margins. 

                  

                  Another reason why this seems like it should be a
                  sub-class over-ride. 

                  

                  

                  Also this looks wrong --- 

                  1672                         if ((imgX*2) + imgWid &gt; wid) { 

                  1673                                 imgWid = wid - imgX*2; 

                  1674                         } 

                  

                  You can't assume equal margins. 

                  

                  -phil. 

                  

                  On 7/12/16, 5:05 AM, Prasanta Sadhukhan wrote: 

                  <blockquote type="cite">Hi All, 

                    

                    Please review a fix for an issue where it is seen
                    that if user sets invalid imageablearea via
                    Paper.setImageableArea and 

                    then calls PrinterJob.validatePage() in linux, then
                    it does not get a valid pageformat 

                    

                    Bug: <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="https://bugs.openjdk.java.net/browse/JDK-6574279">https://bugs.openjdk.java.net/browse/JDK-6574279</a>
  

                    webrev: <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/%7Epsadhukhan/6574279/webrev.00/">http://cr.openjdk.java.net/~psadhukhan/6574279/webrev.00/</a>
  

                    

                    Fix is to check for margin as noted via CUPS
                    ppdPageSize() and then calculate to find the valid
                    margin in validatePaper() 

                    similar to what we do in native validatePaper() in
                    windows. 

                    

                    Regards 

                    Prasanta 

                  </blockquote>
                </blockquote>
                

              </blockquote>
              

            </blockquote>
            

          </blockquote>
          

        </blockquote>
        

      </blockquote>
    </blockquote>
  




</blockquote>
</body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic