0

I have downloaded itext source code from here (downlaod snapshot).

However, I don't know how do I add it to my project so it would work...

If I add the com package, then resources are ommited. If I add a package from higher level, all imports get messed up (it's fixable, but I don't know if there are other consequences).

But whatever I do, I don't have BouncyCastle jars that are needed so all iText classes would function properly, and I know it had some heavy API changes recently so I'm not sure what version is compatible with the version of iText on sourceForge that I downloaded.

I don't even know which and if I downloaded the right version...

Any advice?

Karlovsky120
  • 6,212
  • 8
  • 41
  • 94

1 Answers1

1

you've downloaded the source code. It's better to download the ZIP file from here: http://sourceforge.net/projects/itext/files/iText/iText5.4.3/

The zip file in this directory contains several jars. Normally you'll only need the itextpdf-5.4.3.jar to start with.

The easiest way to build your project from the iText source code (should you wish to do that anyway), is to use the POM file. If you don't know what a POM file is, please search the net for Maven. The POM file allows you to import the project as a Maven Project. This will automatically import all dependencies. (Of course: now I'm assuming that you've installed Maven in Eclipse.)

The reason why the code doesn't compile when you download it, is simple: iText has a dependency on BouncyCastle and if you don't add BouncyCastle to your CLASSPATH, iText won't compile. At runtime, you only need BouncyCastle as soon as you need encryption (password encryption, certificate encryption, digital signatures).

If you wait until Monday, you'll be able to download iText 5.4.4.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • I want the source code because I need to add a setter to one of the classes which is to complicted to extend and has too many other classes depending on it... BTW, while you are here, how come that BaseFont doesn't have a setter for widths[]? Is it going to be added in iText 5.4.4? – Karlovsky120 Sep 13 '13 at 15:35
  • OK, then the best way to build the code, is by using the POM file as explained. Also: there's no way we're ever going to add a setter for `widths[]` in `BaseFont`. We've discussed this at the PDF Technical Conference in Seattle in August (all US PDF specialists were there and they all agreed). I hope you don't add that setter, because it's a really bad idea. It's the kind of change that would "break your warranty" if you were a customer. Why do you want to change those widths? – Bruno Lowagie Sep 13 '13 at 15:37
  • I'm trying to create a PDF which needs to have font which has the as similar dimensions as possible as one in Java swing. I added font.ttf to both and had to reduce the size of the PDF one to 75% of the Swing one (unit-dpi-pixel and stuff), but the widths are still not working. Comparing PDF to Swing, some characters are wider, and some are narrower, it's not even consistent... Some have managed to solve the problem here: http://stackoverflow.com/questions/17998144/java-pdf-text-rendering/18058659#18058659 But I'm not even sure that fix would work in my case... Any ideas? – Karlovsky120 Sep 13 '13 at 15:46
  • 1
    It's a bad idea. I'd need more time to find out how to solve it, but changing the width[] will cause PDF specialists to condemn you to eternal burning in hell ;-) – Bruno Lowagie Sep 14 '13 at 08:41
  • Umm, it seems that all my problems are caused by pixel-to-unit scaling. Have you ever thought of adding a method that would "normalize" any value that are or are added to coordinates - change them to closest value divisible by .75? In standard 96DPI displays that would mean that you could get exact value in pixels by examining one in units. It would scale perfectly. How it is now, if unit value is off by .02, it would accumulate and start adding extra unexpected pixels. For more info: http://stackoverflow.com/questions/18854016/changing-charbbox-itext – Karlovsky120 Sep 17 '13 at 17:12
  • There's no such thing as pixels in PDF. I looked for more info, but your link is broken. – Bruno Lowagie Sep 18 '13 at 07:55
  • Wrong link: http://stackoverflow.com/questions/18860450/adjusting-the-textmatrix-in-itext – Karlovsky120 Sep 18 '13 at 13:09