[OpenJDK 2D-Dev] [9] RFR JDK-6574279: validatePage from PrinterJob returns argument under linux

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Thu Aug 11 08:38:27 UTC 2016


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?

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
>>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20160811/350c97fd/attachment.html>


More information about the 2d-dev mailing list