How to extract GTextArea text to a PDF file

I have a GTextArea (using g4p_controls.*) which has text within it. What would be the easiest way to extract the text from within the GTextArea and output that text to a PDF file? I do not want the control itself to be "printed" to the PDF file, only the text within it.

I am a bit confused by the processing.pdf.* library and don't really understand how to achieve this goal.

I have the string of text that I would like to send to the pdf file: String dataToSave = join(textArea.getTextAsArray(), '\r');

How do I then create the pdf file from that text? This page does not really show how to export text:


  • I have never used the Processing PDF library but I have been working with Java and Apache's PDFBox project for a JavaFX application so I have some knowledge in this area.

    The Processing PDF library saves the screen display as PDF so you need to draw the bare text to the display before saving the PDF. It might be possible to create a separate off-screen graphics context, using createGraphics() that you can draw the text and save that to PDF.

    The PDF will store the text as a bitmap so it can't be edited later.

Sign In or Register to comment.