Alina Anjum
Alina Anjum

Reputation: 1230

Use two Itextsharp versions in same project

I am working on intranet portal where there are many subsystems are linked to the portal . Now the portal is newly developed on .net 4.0 .I have used itextsharp version 5.5.9 in this portal .

Pdf generation is working fine in the project but the problem is when I merge old subsystems with this portal , there's a conflict in itextsharp versions as there's so many things which are not supported in itextsharp 5.5.9 version For Example :

  1. HeaderFooter footer = new HeaderFooter(new Phrase(

  2. myParagraph.SetAlignment

  3. iTextSharp.text.Table tableh = new iTextSharp.text.Table(11);

  4. Cell csr = new Cell(sr);

Above are some examples which are not supported in itextsharp newer versions .

More than 5 subsystems are using itextsharp old version .

As there are so many subsystems to be merged in the portal , I want the way where I could use both the versions of itextsharp .

Is it possible ?

Kindly help

Thanks

Upvotes: 0

Views: 675

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77546

There are different solutions to your problem.

Solution #1: upgrade to the latest version instead of to 5.5.9

You can't use 5.5.9 together with an older version because all of those versions use the same package names. There will be naming conflicts (as you have experienced).

However iText 7 for C# is a complete rewrite of iTextSharp and because of this, we chose different package names. There will be no conflicts when you use iText 7 next to an older version.

This means that you have to rewrite your current version.

Solution #2: rewrite the old code so that it works with iText 5.5.9.

The code that is used by the older applications should not be used in production environments, hence you really should upgrade those applications.

The HeaderFooter class was abandoned in favor of using page events. The Table and Cell class were replaced with PdfPTable and PdfPCell. I don't know about myParagraph.SetAlignment(), but it wouldn't surprise me if it's now myParagraph.Alignment.

Conclusion: both "solutions" require quite some work, but your company seems to have been using iTextSharp for a mighty long time, so it's about time to upgrade anyway.

Upvotes: 1

Related Questions