Thanks for taking the time to answer, Peter and Andrei.
That's precisely what I had in mind, Peter, and thanks for the suggestion. I have a small printing use case where the input is safe, in theory (it's not directly user-provided), but I was thinking just in case it were tampered with, I should avoid a potential vulnerability scenario. Hopefully the sanitization will suffice.
And finally, thanks for maintaining the project. This is my first time attempting to generate PDFs with Java and I'm surprised there's no 'standard' Java API to do these conversions... apart maybe from the paid, cloud-based (and very expensive, afaik) one from Adobe...