You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by ragunath marudhachalam <ra...@gmail.com> on 2015/08/19 20:04:22 UTC
Textbox word wrap and multiline help...
Hello,
In one of the mailing list posting, it was mentioned that pdfbox2.0
snapshot supports multiline in a pdtextbox. I downloaded 2.0 snapshot and
setmultiline to true. But I still get only a single line without word
wrap. I am attaching my code where I set the value for the field and set
multiline to true. Can someone please assist me and suggest how I can get
the word wrap working if the text is larger than the textbox. Thank you
very much for your help and time..
while (fieldsIter.hasNext())
{
PDField field = (PDField) fieldsIter.next();
String fieldName = field.getPartialName();
//logger.error("field name "+ fieldName);
if(field instanceof PDCheckbox)
{
PDCheckbox cb = (PDCheckbox)field;
//cb.check();
}
else
{
if(!field.isReadonly())
{
if(field instanceof PDVariableText)
{
logger.error("variable text");
String fieldNameToCheck = field.getPartialName().substring(0,
3);
if(map.get(fieldNameToCheck) != null)
{
if(field.getPartialName().contains("CURRENCY"))
{
field.setValue("$ "+ (String)map.get(fieldNameToCheck));
}
else if(field.getPartialName().contains("PERCENT"))
{
field.setValue((String)map.get(fieldNameToCheck) +"%");
}
else
{
field.setValue(map.get(fieldNameToCheck));
}
((PDVariableText) field).setMultiline(true);
//field.setReadonly(true);
}
}
else
{
String fieldNameToCheck = field.getPartialName().substring(0,
3);
if(map.get(fieldNameToCheck) != null)
{
if(field.getPartialName().contains("CURRENCY"))
{
field.setValue("$ "+ (String)map.get(fieldNameToCheck));
}
else if(field.getPartialName().contains("PERCENT"))
{
field.setValue((String)map.get(fieldNameToCheck) +"%");
}
else
{
field.setValue(map.get(fieldNameToCheck));
}
//field.setReadonly(true);
}
}
}
}
//processField(pdf, field, "|--", field.getPartialName());
}
}
Re: Textbox word wrap and multiline help...
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,
multiline has to be set before setting the fields value
BR
Maruan
> Am 19.08.2015 um 20:04 schrieb ragunath marudhachalam <ra...@gmail.com>:
>
> Hello,
>
> In one of the mailing list posting, it was mentioned that pdfbox2.0
> snapshot supports multiline in a pdtextbox. I downloaded 2.0 snapshot and
> setmultiline to true. But I still get only a single line without word
> wrap. I am attaching my code where I set the value for the field and set
> multiline to true. Can someone please assist me and suggest how I can get
> the word wrap working if the text is larger than the textbox. Thank you
> very much for your help and time..
>
> while (fieldsIter.hasNext())
> {
> PDField field = (PDField) fieldsIter.next();
> String fieldName = field.getPartialName();
> //logger.error("field name "+ fieldName);
> if(field instanceof PDCheckbox)
> {
> PDCheckbox cb = (PDCheckbox)field;
> //cb.check();
> }
> else
> {
> if(!field.isReadonly())
> {
> if(field instanceof PDVariableText)
> {
> logger.error("variable text");
> String fieldNameToCheck = field.getPartialName().substring(0,
> 3);
> if(map.get(fieldNameToCheck) != null)
> {
> if(field.getPartialName().contains("CURRENCY"))
> {
> field.setValue("$ "+ (String)map.get(fieldNameToCheck));
> }
> else if(field.getPartialName().contains("PERCENT"))
> {
> field.setValue((String)map.get(fieldNameToCheck) +"%");
> }
> else
> {
> field.setValue(map.get(fieldNameToCheck));
> }
> ((PDVariableText) field).setMultiline(true);
> //field.setReadonly(true);
> }
>
> }
> else
> {
> String fieldNameToCheck = field.getPartialName().substring(0,
> 3);
> if(map.get(fieldNameToCheck) != null)
> {
> if(field.getPartialName().contains("CURRENCY"))
> {
> field.setValue("$ "+ (String)map.get(fieldNameToCheck));
> }
> else if(field.getPartialName().contains("PERCENT"))
> {
> field.setValue((String)map.get(fieldNameToCheck) +"%");
> }
> else
> {
> field.setValue(map.get(fieldNameToCheck));
> }
> //field.setReadonly(true);
> }
> }
> }
>
>
> }
> //processField(pdf, field, "|--", field.getPartialName());
> }
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org