'how to break a long text to multiple lines in PDF creation in android?

I have a notebook app and i want to have the notes to be saved as PDF files. the user can write long texts in TextView but when i get the text to string and create a PDF file, only a small part of the text in a single line will be in the PDF file. how can i break the text to multiple lines to see entire text in PDF page? i used this part of java codes to break the text but it does not work.

     textView = findViewById(R.id.textView);

     String pdfText = textView.getText().toString();

     Paint contentPaint = new Paint();
        int length = pdfText.length();
        contentPaint.breakText(pdfText, 0, length, true, 70, null);
        canvas.drawText(pdfText, 30, 285, contentPaint);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source