set Destination attribute in printReqAttrSet

Neacsu Cristian neacsu.cristianstefan at gmail.com
Wed Feb 5 14:05:35 UTC 2020


Awesome :) good to know that is in WIP state.
Really looking forward for it. Good luck in solving the bugs! ^_^

Cristian-Stefan

On Wed, Feb 5, 2020 at 2:16 AM Philip Race <philip.race at oracle.com> wrote:

> I found that there were some bugs in the JDK code that FX calls
> that need to be fixed first. I started on those but it was reasonably
> complex to test and so that is still WIP and then the FX part should
> be possible.
>
> -phil.
>
> On 2/4/20, 2:52 AM, Neacsu Cristian wrote:
>
> Hello,
>
> Any updates regarding this matter? :-s
>
> Thank you in advance,
> Cristian-Stefan
>
> On Sat, May 11, 2019 at 2:36 AM Neacsu Cristian <
> neacsu.cristianstefan at gmail.com> wrote:
>
>> Damn ... Thank you for your reply and for the ticket submitted.
>> I created an invoice application for my own company, and imagine that
>> java 9+ would kill me :) All the invoices are generated automatically
>> through pdf printer (I tried few free pdf libraries as an alternative, but
>> for what I need they have poor results).
>>
>> I actually posted my ugly solution as well here some time ago:
>>
>> https://stackoverflow.com/questions/52684422/javafx-set-programmatically-the-destination-path-to-print-directly-a-node-to-p/52687798#52687798
>>
>> I know it is not much, but 89 hits might mean something. People might
>> fight with it later, when they are going to migrate for new java versions.
>>
>> Thank you so much, and looking forward if you guys have time to take care
>> of it.
>>
>> Cristian-Stefan
>>
>>
>>
>> On Fri, May 10, 2019 at 8:15 PM Philip Race <philip.race at oracle.com>
>> wrote:
>>
>>> Everything you are touching there pre-supposes knowledge
>>> of today's implementation of the JavaFX printing API, so
>>> I don't think we can endorse that.
>>> The right thing to do (maybe years ago!) is to file
>>> an RFE to request that something like the Destination attribute
>>> be supported in the FX printing API. I've reviewed the open
>>> bug list and I don't see that anyone else has asked for this.
>>>
>>> I just submitted : https://bugs.openjdk.java.net/browse/JDK-8223717
>>>
>>> JFYI, I reviewed some old notes and it was originally planned to be
>>> supported in the API but during design discussion it was removed
>>> as a result of a combination of getting it right, not being sure how
>>> many people would need it (you may be the first) and some perhaps
>>> over-stated concerns about security.
>>>
>>> -phil.
>>>
>>> On 5/10/19, 1:39 AM, Neacsu Cristian wrote:
>>> > For windows print through "Microsoft Print to PDF", there is no way
>>> right
>>> > now to pre-define a path programmatically. There is no way to set
>>> inside
>>> > the printReqAttrSet (J2DPrinterJob), an attribute of type Destination,
>>> to
>>> > solve this issue.
>>> >
>>> > Before jdk 9, I was bypassing it through reflection like this:
>>> >
>>> > java.lang.reflect.Field field =
>>> job.getClass().getDeclaredField("jobImpl");
>>> > field.setAccessible(true);
>>> > PrinterJobImpl jobImpl = (PrinterJobImpl) field.get(job);
>>> > field.setAccessible(false);
>>> > field = jobImpl.getClass().getDeclaredField("printReqAttrSet");
>>> > field.setAccessible(true);
>>> > PrintRequestAttributeSet printReqAttrSet = (PrintRequestAttributeSet)
>>> > field.get(jobImpl);
>>> > field.setAccessible(false);
>>> > printReqAttrSet.add(new Destination(new File(filePath).toURI()));
>>> >
>>> > Now, the module is closed, so I cannot access it through reflection. Is
>>> > there a way to obtain this behavior again?
>>>
>>


More information about the openjfx-dev mailing list