How do you create a good PDF Document in android with Java?


I have checked examples around for PDF document generation in android and most of them use a canvas and paint the text on it. But I want to write text, text that can be selected like on other PDFs. So, how do you do that?

I have used the PDFDocument object but that doesn’t seem to have many options for its pages. And creating a document doesn’t seem to work either.
I have also seen many people use the Pdfwriter but I can’t seem to find it in Android studio. Nor can I simply generate a document with Document document = new Document(); which many have used.