In this section, you will learn how we can measure the width of the page. iText api provides a getWidthPoint() to know the width of the page. The width will be in centimeters or inches.
If we have a Chunk and we want to know it's width on a page then we can use the method getWidthPoint(). It gives us the width in points and we will have to do maths to know the width in inches or centimeters.
With the method setHorizontalScaling(float scale), we can shrink (scale < 1.0f) or expand (scale > 1.0f) the Chunk. In the example we first print the Chunk in its actual size, then we print it twice at half its size (scale = 0.5f).
The code of the program is given below:
The output of the program is given below:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.