What I try to achieve, is to use "Microsoft Print to PDF" without inserting the path manually. In java 8 was possible to force adding that Destination parameter through reflection (again an ugly hack), because the API do not expose it. Now being encapsulated in Java 9+ is not achievable anymore... I need to generate automatically 50 nodes (which represents invoices) as PDF.
On Tue, Feb 4, 2020 at 4:18 PM Dan Howard <spro...@videotron.ca> wrote: > Have you tried using normal printing in Java? Just to print something > with the usual AWT etc APIs. If that works you could convert the node > to an image to print. > > > On 2/4/2020 5: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.cristianste...@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.r...@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? >