2

I have a requirement to add few lines at the top of an existing PDF. I have done this using a PdfReader and a PdfStamper. In order to have more space in the page header area, i need to move down the current contents by 1 or 2 lines. Below is from the forum. but it doesn't solve the issue. How to insert content in the middle of a page in a PDF using IText

Any suggestions?

-i can not upload the pdf or the image of the pdf because am a new user

Community
  • 1
  • 1
Reji
  • 23
  • 1
  • 3

1 Answers1

2

Do I interpret your question correctly if I assume that you really want to move down everything on the page and add some lines above?

You can do that by changing the media box (and crop box and what other boxes might be explicitly defined for your page) and then add the few lines on top the same way you already do it now.

You can access those boxes in the respective page dictionary which you can retrieve via the PdfReader. Look up the PDF specification for details on those boxes.

Or do I interpret you incorrectly and you only want to move down some text while keeping existing headers and footers in place? In that case Alexis' answer to the other question you refer to still holds.

mkl
  • 90,588
  • 15
  • 125
  • 265
  • Thank you!! This is exactly what my requirement is. I was able to get the media box (no other boxes are present in the page) from page dictionary. And then used `mediaBox.set()` to gain space in the page header. I had found another link while searching for this. http://stackoverflow.com/questions/4089757/how-do-i-resize-an-existing-pdf-with-coldfusion-itext Thanks Once agian for your quick response. – Reji Oct 10 '12 at 12:56