<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Did you mean javafx.print.Paper instead of java.print.Page?</p>
<p>If so, then I think that the getWidth/getHeight functions should
be fixed as they're not specified to do any rounding. They return
a double, and specify they return this in points. Nowhere does it
mention they're rounded to an integer number of points (in which
case I would also expect an integer return type). This seems an
obvious bug.</p>
<p>--John</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 31/08/2023 11:39, Florian Kirmaier
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CA+4mSqYVQDCY8YSrJq7W-s=yTs7DFYu-geAHT4x7hDOiuG-8Aw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Hi JavaFX Developer!<br>
<br>
The Problem:<br>
<br>
On the class <a href="http://java.print.page/" target="_blank"
moz-do-not-send="true">java.print.Page</a>, the methods
“getWidth" and “getHeight" don’t return the correct values.<br>
<br>
It especially causes problems when the Paper is defined in mm.<br>
This happens mainly because of this method, which rounds down to
full points:<br>
<br>
private double getSizeInPoints(double dim) {<br>
switch (units) {<br>
case POINT : return (int)(dim+0.5);<br>
case INCH : return (int)((dim * 72) + 0.5);<br>
case MM : return (int)(((dim * 72) / 25.4) + 0.5);<br>
}<br>
return dim;<br>
}<br>
<br>
This causes problem because it makes correct computations based
on the Paper impossible.<br>
So it’s basically not possible to get the size of any Paper
which is defined based on mm.<br>
<br>
There I suggest 3 solutions:<br>
<br>
<b>Solution1:</b><br>
We could just change getSIzeInPoints to return the exact value.<br>
Advantage: Might fix various unknown bugs in user code.<br>
Disadvantage: Might cause regressions.<br>
<br>
<b>Solution2:</b><br>
We could add new methods getExactWidth() / getExactHeight() ,
which returns the exact value without a rounding problem
anywhere noticeable.<br>
<br>
<b>Solution3:</b><br>
We could provide an API to access the width/height based on a
given Unit.<br>
like: getWidth(Unit.MM).<br>
We already have implemented this, in our application code, so it
wouldn’t be much effort.<br>
But it would require moving com.sun.javafx.print.Units back to
javafx.print.Paper.Units. (basically reverting JDK-8093699)<br>
<br>
<br>
<b>Summary:</b><br>
I am happy with every solution.<br>
I’m a bit in favor of 1, but 2 and 3 is also ok for me.<br>
It would be great if someone could make a decision on which
solution to choose, then i would provide a PR.<br>
<br>
Greetings Florian Kirmaier<br>
</div>
</blockquote>
</body>
</html>