• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

itext 5 trying to add image and text to header in every page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

i am trying to add an image and text to the header of each and every page.

for adding simple text in to header. earlier i tried creating with below lines of code:

String final_header = "hello"+" "+writer.getPageNumber();

ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(String.format("%s", final_header),FooterFont), (document.right() - document.left()) / 2 + document.leftMargin(), document.top() + 10, 0);


and the output is like " hello 1" on the first page. it works fine.

but now i am trying to add an image and page number to the header.

it would be really greatful if any one share experience on the same.

thanks
rakesh
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See https://coderanch.com/how-to/java/ItextExample for how to create headers and footers. By the way, you're aware that itext 5 requires you obtain a paid license for just about any commercial use, yes? (Unless you want to distribute the source code of your app widely.)
 
rakesh nadiminti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply..
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!