Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how i can add header to each PDF page using iText 2.7.1

 
manushree deepak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

how i can add header/footer to each PDF page using iText 2.7.1.

I am capturing header and footer as a html tag from UI.I want to add header and footer to each PDf page.
Please help me.


Thank you.
 
Karthik Jayachandran
Ranch Hand
Posts: 91
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is never been a 2.7.1 version of iText. Did you mean 2.1.7?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See https://www.coderanch.com/how-to/java/ItextExample for a full example.
 
manushree deepak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Karthik Jayachandran : sorry itext version is 2.1.7 .

@Ulf Dittmer : I gone through the example provided.I have a header info which is stored in db like,

ex : <div style="text-align: center;"><b><font size="2" color="#ff0000">Header</font></b></div>

I want to render this in PDF as header .Please help me.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iText is a Java API. What does HTML have to do with it?
 
Karthik Jayachandran
Ranch Hand
Posts: 91
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Ref.

Note: Not sure whether html style would render to pdf too.
 
manushree deepak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of giving user a static header style we allow user defined style.Please let me know whether its possible in itext or is there any other tool?
 
Karthik Jayachandran
Ranch Hand
Posts: 91
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is possible in iText. Create the earlier mentioned Phrase as separate objects and then add the required styles (Fonts, size, color, etc) to the phrase objects.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be more specific what a "user defined style" is? How and when is that determined and applied?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic