Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Changing form field value text size

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Evening

I'm using the following code:

PdfReader reader = new PdfReader(inname);
AcroFields fields = stamper.getAcroFields();
// AcroFields fields = reader.getAcroFields();
   setthecharsize();
  Set<String> fldNames = fields.getFields().keySet();

       // insert here, possible call to methd here passing field name (or new value containing) the company name, and the size of the characters)
       fields.setField("Your Company Name:", "Capitol Heights Property Maintenance"); // Form field length 19
       
        // insert here, possible call to methd here passing field name (or new value containing) the company name, and the size of the characters)
       fields.setField("Your Company Name", "Capitol Heights Property Maintenance"); // form field length < 33

for (String fldName : fldNames) {
 System.out.println( fldName + ": " + fields.getField( fldName ) );}
stamper.close();
    } catch (IOException e) {
e.printStackTrace();


Im wanting to create a method that I can pass in a "form field name" and character size value to a method and change the character size. The 2 form fields
I want to change are named  "Your Company Name" and "your Name" and set them to a smaller size
Using the above code the PDF file produces

field named "Your Company Name">> Capitol Heights Property M
field named "Your Name" >>> ""

I would like to create  a method that I can pass any field name and change the size of the out characters. I have been googleing and getting how the change the fiels size, how to change a jbox size, etc... The closest this I found was textField.setFont command. I was hoping I  could simply change the size of the text the return and fill the form value with smaller/littler characters with the fields.setField("Your Company Name:" code

Thanks in advance for your help!! }
 
Rancher
Posts: 508
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Im wanting to create a method that I can pass in a "form field name" and character size value to a method and change the character size. ...
I would like to create  a method that I can pass any field name and change the size of the out characters...



This is your first post here. Please UseCodeTags and format text the next time you post (so that its little readable). Also, noted that you have already posted the message on StackOverflow.

What version of iText you are using (the code you are writing is using iText software, correct)?

I think there are two questions you are asking here:
1. How to set the text/font size for a field/form field
2. Create a method that takes field name and font/character size as parameters and sets the size

Here are couple of links to start with at the iText website, regarding fonts:
- https://developers.itextpdf.com/de/node/1908
- https://developers.itextpdf.com/content/itext-7-building-blocks/chapter-1 (look for a sub-topic titled Font properties)

My suggestion: First get the code correctly working to change the text size for the fields. Then, use that code to create the method, later.
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prasad Saya wrote: Also, noted that you have already posted the message on StackOverflow.  


Can you post the URL of the other thread when you find it?  I looked for it, but came up empty.

And of course, the ultimate responsibility to do this is the OP's.
 
Prasad Saya
Rancher
Posts: 508
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:

Prasad Saya wrote: Also, noted that you have already posted the message on StackOverflow.  


Can you post the URL of the other thread when you find it?  I looked for it, but came up empty...



I thought I kept a copy of the URL (of the stackoverflow post) but, lost it somewhere; I am pretty sure I saw it. Though the OP's name used was little different (the first name was different, or it was just an initial). The content of the post was the same (including the formatting or style). But, in that post there was a mention that iText was the software.
 
boofoni Brown
Greenhorn
Posts: 5
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prasad Saya thanks anyways... I'm using itext5. I see in the examples how to set the field (which I'm already doing), setting the color, etc. The answer was like asking Jeff gordan how to best pass the car in front of you, and he responds well you are a beginning driver and gives you copies of all of his races on tape and keys to a car or helping someone learn to fish from your garage by giving a person a fishing pole a tackle box then wonder why he didnt catch any fish. Example I helped sidmeone make a disk, I pulled up the youtube video, showed them how to pause the vid and we selp by step went through the vid until the dish was completed.
I hope that you are not at work and ask the subject matter expert a question and he/she hands you their text book.
I'm nicely trying to say, if you dont want to help a beginner, then don't respond to a post for help

Have a great day
 
Prasad Saya
Rancher
Posts: 508
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't used iText before either. I was just trying to help.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic