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:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: March 13, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles