File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
rakesh nadiminti
Greenhorn
Posts: 2
  • 0
  • 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
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See https://www.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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic