Multiline fields
Examples with multi-line text fields.
multilinefield
JAVA
JAVA
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Authors: Apryse Software.
For more information, please contact iText Software at this address:
sales@itextpdf.com
*/
package com.itextpdf.samples.sandbox.acroforms;
import com.itextpdf.forms.fields.PdfFormCreator;
import com.itextpdf.forms.fields.TextFormFieldBuilder;
import com.itextpdf.io.source.IRandomAccessSource;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.io.source.ByteArrayOutputStream;
import com.itextpdf.io.source.RandomAccessSourceFactory;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfFormField;
import com.itextpdf.forms.fields.PdfTextFormField;
import com.itextpdf.kernel.pdf.ReaderProperties;
import java.io.File;
public class MultiLineField {
public static final String DEST = "./target/sandbox/acroforms/multi_line_field.pdf";
public static final String FIELD_NAME = "text";
public static void main(String[] args) throws Exception {
File file = new File(DEST);
file.getParentFile().mkdirs();
new MultiLineField().manipulatePdf(DEST);
}
protected void manipulatePdf(String dest) throws Exception {
// createForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = createForm();
IRandomAccessSource source = new RandomAccessSourceFactory().createSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
form.getField(FIELD_NAME).setValue(
"A B C D E F\nG H I J K L M N\nO P Q R S T U\r\nV W X Y Z\n\nAlphabet street");
// If no fields have been explicitly included, then all fields are flattened.
// Otherwise only the included fields are flattened.
form.flattenFields();
pdfDoc.close();
}
public byte[] createForm() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
Rectangle rect = new Rectangle(36, 720, 108, 86);
PdfTextFormField textFormField = new TextFormFieldBuilder(pdfDoc, FIELD_NAME)
.setWidgetRectangle(rect).createText();
textFormField.setValue("text");
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textFormField.setMultiline(true);
PdfFormCreator.getAcroForm(pdfDoc, true).addField(textFormField);
pdfDoc.close();
return baos.toByteArray();
}
}
C#
C#
using System;
using System.IO;
using iText.Forms;
using iText.Forms.Fields;
using iText.IO.Source;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
namespace iText.Samples.Sandbox.Acroforms
{
public class MultiLineField
{
public static readonly String DEST = "results/sandbox/acroforms/multi_line_field.pdf";
public static readonly String FIELD_NAME = "text";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new MultiLineField().ManipulatePdf(DEST);
}
protected void ManipulatePdf(String dest)
{
// createForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = CreateForm();
IRandomAccessSource source = new RandomAccessSourceFactory().CreateSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
form.GetField(FIELD_NAME)
.SetValue("A B C D E F\nG H I J K L M N\nO P Q R S T U\r\nV W X Y Z\n\nAlphabet street");
// If no fields have been explicitly included, then all fields are flattened.
// Otherwise only the included fields are flattened.
form.FlattenFields();
pdfDoc.Close();
}
public virtual byte[] CreateForm()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
Rectangle rect = new Rectangle(36, 720, 108, 86);
PdfTextFormField textFormField =
new TextFormFieldBuilder(pdfDoc, FIELD_NAME).SetWidgetRectangle(rect).CreateText();
textFormField.SetValue("text");
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textFormField.SetMultiline(true);
PdfFormCreator.GetAcroForm(pdfDoc, true).AddField(textFormField);
pdfDoc.Close();
return baos.ToArray();
}
}
}
readonlyfield
JAVA
JAVA
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Authors: Apryse Software.
For more information, please contact iText Software at this address:
sales@itextpdf.com
*/
package com.itextpdf.samples.sandbox.acroforms;
import com.itextpdf.forms.fields.PdfFormCreator;
import com.itextpdf.forms.fields.TextFormFieldBuilder;
import com.itextpdf.io.source.IRandomAccessSource;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.io.source.ByteArrayOutputStream;
import com.itextpdf.io.source.RandomAccessSourceFactory;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.ReaderProperties;
import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfFormField;
import com.itextpdf.forms.fields.PdfTextFormField;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class ReadOnlyField {
public static final String DEST = "./target/sandbox/acroforms/read_only_field.pdf";
public static void main(String[] args) throws Exception {
File file = new File(DEST);
file.getParentFile().mkdirs();
new ReadOnlyField().manipulatePdf(DEST);
}
protected void manipulatePdf(String dest) throws Exception {
// createForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = createForm();
IRandomAccessSource source = new RandomAccessSourceFactory().createSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
form.getField("text")
// Method sets the flag, specifying whether or not the field can be changed.
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
pdfDoc.close();
}
public byte[] createForm() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
PdfFont font = PdfFontFactory.createFont();
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
Rectangle rect = new Rectangle(36, 770, 104, 36);
PdfTextFormField textField = new TextFormFieldBuilder(pdfDoc, "text")
.setWidgetRectangle(rect).createText();
textField.setValue("text").setFont(font).setFontSize(20f);
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textField.setMultiline(true);
form.addField(textField);
pdfDoc.close();
return baos.toByteArray();
}
}
C#
C#
using System;
using System.IO;
using iText.Forms;
using iText.Forms.Fields;
using iText.IO.Source;
using iText.Kernel.Font;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
namespace iText.Samples.Sandbox.Acroforms
{
public class ReadOnlyField
{
public static readonly String DEST = "results/sandbox/acroforms/read_only_field.pdf";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new ReadOnlyField().ManipulatePdf(DEST);
}
protected void ManipulatePdf(String dest)
{
// CreateForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = CreateForm();
IRandomAccessSource source = new RandomAccessSourceFactory().CreateSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
form.GetField("text")
// Method sets the flag, specifying whether or not the field can be changed.
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
pdfDoc.Close();
}
public byte[] CreateForm()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
PdfFont font = PdfFontFactory.CreateFont();
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
Rectangle rect = new Rectangle(36, 770, 104, 36);
PdfTextFormField textField = new TextFormFieldBuilder(pdfDoc, "text").SetWidgetRectangle(rect).CreateText();
textField.SetValue("text").SetFont(font).SetFontSize(20f);
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textField.SetMultiline(true);
form.AddField(textField);
pdfDoc.Close();
return baos.ToArray();
}
}
}
readonlyfield2
JAVA
JAVA
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Authors: Apryse Software.
For more information, please contact iText Software at this address:
sales@itextpdf.com
*/
package com.itextpdf.samples.sandbox.acroforms;
import com.itextpdf.forms.fields.PdfFormCreator;
import com.itextpdf.forms.fields.TextFormFieldBuilder;
import com.itextpdf.io.source.IRandomAccessSource;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.io.source.ByteArrayOutputStream;
import com.itextpdf.io.source.RandomAccessSourceFactory;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.ReaderProperties;
import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfTextFormField;
import java.io.File;
import java.io.IOException;
public class ReadOnlyField2 {
public static final String DEST = "./target/sandbox/acroforms/read_only_field2.pdf";
public static void main(String[] args) throws Exception {
File file = new File(DEST);
file.getParentFile().mkdirs();
new ReadOnlyField2().manipulatePdf(DEST);
}
protected void manipulatePdf(String dest) throws Exception {
// createForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = createForm();
IRandomAccessSource source = new RandomAccessSourceFactory().createSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
form.getField("text1")
// Method sets the flag, specifying whether or not the field can be changed.
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.getField("text2")
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.getField("text3")
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.getField("text4")
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
pdfDoc.close();
}
public byte[] createForm() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
PdfFont font = PdfFontFactory.createFont();
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
Rectangle rect = new Rectangle(36, 770, 108, 36);
PdfTextFormField textField1 = new TextFormFieldBuilder(pdfDoc, "text1")
.setWidgetRectangle(rect).createText();
textField1.setValue("text1").setFont(font).setFontSize(18f);
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textField1.setMultiline(true);
form.addField(textField1);
rect = new Rectangle(148, 770, 108, 36);
PdfTextFormField textField2 = new TextFormFieldBuilder(pdfDoc, "text2")
.setWidgetRectangle(rect).createText();
textField2.setValue("text2").setFont(font).setFontSize(18f);
textField2.setMultiline(true);
form.addField(textField2);
rect = new Rectangle(36, 724, 108, 36);
PdfTextFormField textField3 = new TextFormFieldBuilder(pdfDoc, "text3")
.setWidgetRectangle(rect).createText();
textField3.setValue("text3").setFont(font).setFontSize(18f);
textField3.setMultiline(true);
form.addField(textField3);
rect = new Rectangle(148, 727, 108, 33);
PdfTextFormField textField4 = new TextFormFieldBuilder(pdfDoc, "text4")
.setWidgetRectangle(rect).createText();
textField4.setValue("text4").setFont(font).setFontSize(18f);
textField4.setMultiline(true);
form.addField(textField4);
pdfDoc.close();
return baos.toByteArray();
}
}
C#
C#
using System;
using System.IO;
using iText.Forms;
using iText.Forms.Fields;
using iText.IO.Source;
using iText.Kernel.Font;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
namespace iText.Samples.Sandbox.Acroforms
{
public class ReadOnlyField2
{
public static readonly String DEST = "results/sandbox/acroforms/read_only_field2.pdf";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new ReadOnlyField2().ManipulatePdf(DEST);
}
protected void ManipulatePdf(String dest)
{
// CreateForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = CreateForm();
IRandomAccessSource source = new RandomAccessSourceFactory().CreateSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
form.GetField("text1")
// Method sets the flag, specifying whether or not the field can be changed.
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.GetField("text2")
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.GetField("text3")
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.GetField("text4")
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
pdfDoc.Close();
}
public byte[] CreateForm()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
PdfFont font = PdfFontFactory.CreateFont();
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
Rectangle rect = new Rectangle(36, 770, 108, 36);
PdfTextFormField textField1 = new TextFormFieldBuilder(pdfDoc, "text1")
.SetWidgetRectangle(rect).CreateText();
textField1.SetValue("text1").SetFont(font).SetFontSize(18f);
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textField1.SetMultiline(true);
form.AddField(textField1);
rect = new Rectangle(148, 770, 108, 36);
PdfTextFormField textField2 = new TextFormFieldBuilder(pdfDoc, "text2")
.SetWidgetRectangle(rect).CreateText();
textField2.SetValue("text2").SetFont(font).SetFontSize(18f);
textField2.SetMultiline(true);
form.AddField(textField2);
rect = new Rectangle(36, 724, 108, 36);
PdfTextFormField textField3 = new TextFormFieldBuilder(pdfDoc, "text3")
.SetWidgetRectangle(rect).CreateText();
textField3.SetValue("text3").SetFont(font).SetFontSize(18f);
textField3.SetMultiline(true);
form.AddField(textField3);
rect = new Rectangle(148, 727, 108, 33);
PdfTextFormField textField4 = new TextFormFieldBuilder(pdfDoc, "text4")
.SetWidgetRectangle(rect).CreateText();
textField4.SetValue("text4").SetFont(font).SetFontSize(18f);
textField4.SetMultiline(true);
form.AddField(textField4);
pdfDoc.Close();
return baos.ToArray();
}
}
}
readonlyfield3
JAVA
JAVA
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Authors: Apryse Software.
For more information, please contact iText Software at this address:
sales@itextpdf.com
*/
package com.itextpdf.samples.sandbox.acroforms;
import com.itextpdf.forms.fields.PdfFormCreator;
import com.itextpdf.forms.fields.TextFormFieldBuilder;
import com.itextpdf.io.source.IRandomAccessSource;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.io.source.ByteArrayOutputStream;
import com.itextpdf.io.source.RandomAccessSourceFactory;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.ReaderProperties;
import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfFormField;
import com.itextpdf.forms.fields.PdfTextFormField;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class ReadOnlyField3 {
public static final String DEST = "./target/sandbox/acroforms/read_only_field3.pdf";
public static void main(String[] args) throws Exception {
File file = new File(DEST);
file.getParentFile().mkdirs();
new ReadOnlyField3().manipulatePdf(DEST);
}
protected void manipulatePdf(String dest) throws Exception {
// createForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = createForm();
IRandomAccessSource source = new RandomAccessSourceFactory().createSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
// Set a flag specifying whether to construct appearance streams and appearance dictionaries
// for all widget annotations in the document.
form.setNeedAppearances(true);
form.getField("text1")
// Method sets the flag, specifying whether or not the field can be changed.
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.getField("text2")
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.getField("text3")
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.getField("text4")
.setReadOnly(true)
.setValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
pdfDoc.close();
}
public byte[] createForm() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true);
PdfFont font = PdfFontFactory.createFont();
Rectangle rect = new Rectangle(36, 770, 108, 36);
PdfTextFormField textField1 = new TextFormFieldBuilder(pdfDoc, "text1")
.setWidgetRectangle(rect).createText();
textField1.setValue("text1").setFont(font).setFontSize(18f);
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textField1.setMultiline(true);
form.addField(textField1);
rect = new Rectangle(148, 770, 108, 36);
PdfTextFormField textField2 = new TextFormFieldBuilder(pdfDoc, "text2")
.setWidgetRectangle(rect).createText();
textField2.setValue("text2").setFont(font).setFontSize(18f);
textField2.setMultiline(true);
form.addField(textField2);
rect = new Rectangle(36, 724, 108, 36);
PdfTextFormField textField3 = new TextFormFieldBuilder(pdfDoc, "text3")
.setWidgetRectangle(rect).createText();
textField3.setValue("text3").setFont(font).setFontSize(18f);
textField3.setMultiline(true);
form.addField(textField3);
rect = new Rectangle(148, 727, 108, 33);
PdfTextFormField textField4 = new TextFormFieldBuilder(pdfDoc, "text4")
.setWidgetRectangle(rect).createText();
textField4.setValue("text4").setFont(font).setFontSize(18f);
textField4.setMultiline(true);
form.addField(textField4);
pdfDoc.close();
return baos.toByteArray();
}
}
C#
C#
using System;
using System.IO;
using iText.Forms;
using iText.Forms.Fields;
using iText.IO.Source;
using iText.Kernel.Font;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
namespace iText.Samples.Sandbox.Acroforms
{
public class ReadOnlyField3
{
public static readonly String DEST = "results/sandbox/acroforms/read_only_field3.pdf";
public static void Main(String[] args)
{
FileInfo file = new FileInfo(DEST);
file.Directory.Create();
new ReadOnlyField3().ManipulatePdf(DEST);
}
protected void ManipulatePdf(String dest)
{
// CreateForm() method creates a temporary document in the memory,
// which then will be used as a source while writing to a real document
byte[] content = CreateForm();
IRandomAccessSource source = new RandomAccessSourceFactory().CreateSource(content);
PdfDocument pdfDoc = new PdfDocument(new PdfReader(source, new ReaderProperties()), new PdfWriter(dest));
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
// Set a flag specifying whether to construct appearance streams and appearance dictionaries
// for all widget annotations in the document.
form.SetNeedAppearances(true);
form.GetField("text1")
// Method sets the flag, specifying whether or not the field can be changed.
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.GetField("text2")
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.GetField("text3")
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
form.GetField("text4")
.SetReadOnly(true)
.SetValue("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
pdfDoc.Close();
}
public byte[] CreateForm()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos));
PdfFont font = PdfFontFactory.CreateFont();
PdfAcroForm form = PdfFormCreator.GetAcroForm(pdfDoc, true);
Rectangle rect = new Rectangle(36, 770, 108, 36);
PdfTextFormField textField1 = new TextFormFieldBuilder(pdfDoc, "text1")
.SetWidgetRectangle(rect).CreateText();
textField1.SetValue("text1").SetFont(font).SetFontSize(18f);
// Being set as true, the field can contain multiple lines of text;
// if false, the field's text is restricted to a single line.
textField1.SetMultiline(true);
form.AddField(textField1);
rect = new Rectangle(148, 770, 108, 36);
PdfTextFormField textField2 = new TextFormFieldBuilder(pdfDoc, "text2")
.SetWidgetRectangle(rect).CreateText();
textField2.SetValue("text2").SetFont(font).SetFontSize(18f);
textField2.SetMultiline(true);
form.AddField(textField2);
rect = new Rectangle(36, 724, 108, 36);
PdfTextFormField textField3 = new TextFormFieldBuilder(pdfDoc, "text3")
.SetWidgetRectangle(rect).CreateText();
textField3.SetValue("text3").SetFont(font).SetFontSize(18f);
textField3.SetMultiline(true);
form.AddField(textField3);
rect = new Rectangle(148, 727, 108, 33);
PdfTextFormField textField4 = new TextFormFieldBuilder(pdfDoc, "text4")
.SetWidgetRectangle(rect).CreateText();
textField4.SetValue("text4").SetFont(font).SetFontSize(18f);
textField4.SetMultiline(true);
form.AddField(textField4);
pdfDoc.Close();
return baos.ToArray();
}
}
}