Does anyone have any advice on printing documents ...
# getting-started
j
Does anyone have any advice on printing documents from a kotlin desktop app? I need to be able to create printable documents from database data. I've looked at PDFBox (create PDF's that can later be printed) but I really want a clean idiomatic kotlin way of doing it?
i
pretty sure there is no Kotlin “idiomatic” way here 🙂 good old Java AWT could help: https://docs.oracle.com/javase/tutorial/2d/printing/printable.html
another way could be some IPP lib, there are Kotlin implementations, for example: https://github.com/gmuth/ipp-client-kotlin
j
i'm using tornadofx so I'm thinking it might be possible to implement this https://docs.oracle.com/javase/8/javafx/api/javafx/print/PrinterJob.html
i
should also work, don’t know details of your use case, but it seems IPP is the most universal solution, since you’ve mentioned you need to print random documents
j
well the documents would be created from my app. If I can avoid that intermediate step by just printing the data straight from javafx that seems a better solution, provided I can get it to scale correctly to a sheet of paper.
r
Getting the data to fit correctly on a page is exactly what "creating a document" means. It's basically just taking data and associating layout information with it.
j
unless I am missing something it seems ipp needs a formatted document to process for printing. One of the issues I am having is figuring out a way to get the data formatted to a printable document.