0

I am trying to create a pdf using the itext library. I want to create a pdf where the width of pdf is fixed at 3.020cms and height is auto adjustable according to the text

I found that we need to create a Document object of itext where we can specify the page size like:

Document document = new Document(PageSize.A4, 0, 0, 0, 0);

The first parameter as I found is a Rectangle object of itext. In the api of Rectangle I could not find any readymade constuctor where I can only specify the width to a particular value and set height as auto. Could anyone suggest how can i create a pdf of where width is fixed to 3.020cms but height is auto. Thanks in advance.

Jeets
  • 3,189
  • 8
  • 34
  • 50
  • *height as auto* - What do you mean by *auto*? Page height is a number. – mkl Jun 29 '16 at 11:11
  • I mean height of the pdf should be according to text i.e text should wrap beyond 3.5cms width ( width of pdf is fixed 3.5 cms ) and depending on length of text the height should vary – Jeets Jun 29 '16 at 11:28
  • 1
    Height as auto is a concept that doesn't exist in PDF, so you'll have to use a workaround. I've answered this question before. I'll look for my answer and close the question as a duplicate if possible. – Bruno Lowagie Jun 29 '16 at 11:59

0 Answers0