Question

scaleToFitLineWhenOverflow

Indicates if the image should be scaled to fit the line when the image exceeds the available width. How to implement this in iText2.1.7 ?

Was it helpful?

Solution 2

There is no such version as iText 2.7.1. I assume that you're talking about iText 2.1.7.

iText 2.1.7 is 5 years old. Plenty of bugs have been fixed during those years, plenty of new functionality has been added. The scaleToFitLineWhenOverflow is part of that new functionality. If you want to use it, please use a more recent version of iText. All versions prior to iText 5 (and all versions in the 5.2.x range) were "End Of Life" a couple of years ago. They are no longer supported. No further development will be done on those versions. Please read the FAQ for more background info.

OTHER TIPS

If you are stuck with that version then it is relatively easy to achive your goal. That version already has lots of scaling methods:

  • scaleAbsoluteWidth(float newWidth)
  • scaleToFit(float fitWidth, float fitHeight)
  • scalePercent(float percent)
  • scalePercent(float percentX, float percentY)

So you could scale your image that it automatically fits. Just play around with some of the scaling options...

img.scaleAbsoluteWidth(lineWidth);

or scale it

img.scalePercent(lineWidth / img.getWidth());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top