Remove appearance of TextField in droidText : Android

Posted by AnujAroshA on Stack Overflow See other posts from Stack Overflow or by AnujAroshA
Published on 2012-09-18T08:35:25Z Indexed on 2012/09/18 15:38 UTC
Read the original article Hit count: 647

I am trying to create a PDF using droidText library. There I want to place some text content in the middle of the page but align to left. I was unable to do with Paragraph class and setAlignment() method. So I have decided to use TextField class. Below is the code I have used,

Document document = new Document(PageSize.A4);

try {

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "TextFields.pdf"));

    document.open();

    TextField tf = new TextField(writer, new Rectangle(100, 300, 200, 350), "Content");
    tf.setText("This is the content of text field");
    tf.setAlignment(Element.ALIGN_CENTER);
    tf.setOptions(TextField.MULTILINE | TextField.REQUIRED);

    PdfFormField field = tf.getTextField();
    writer.addAnnotation(field);

} catch (DocumentException de) {
    System.err.println(de.getMessage());
} catch (IOException ioe) {
    System.err.println(ioe.getMessage());
}

document.close();

Code works perfect, but the out put PDF file that I am getting has this TextField which can be editable and also change the font appearance when I am click on the TextField. I don't want that in to my final PDF. How can I remove that attribute? If it is not possible, is there any other way I can position some text in a PDF file using droidText library in Android?

© Stack Overflow or respective owner

Related posts about android

Related posts about pdf-generation