iTextSharp - where are PdfDocument, PdfCanvas, ...?

1.4k Views Asked by At

I'm generating PDF documents using iText(Sharp). I'm developing the app using Visual Studio 2017. I've added iTestSharp using NuGet and I've experimented with both VB and C#

All is fine for the 'high-level' stuff (chapter 1 from the jumpstart tutorial). Now I want to go more low-level using 'page', 'canvas' and 'low-level' drawing commands : chapter 2 from the jumpstart tutorial

http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/chapter-2-adding-low-level-content

My problem is that I can't access the classes PdfDocument, PdfCanvas, etc. these classes are not available.. Also I can't create a New PdfWriter object (New operator is not implemented)

What's wrong ?

  • am I missing some Imports / using libraries ? (I currently include iTextSharp.text and iTextSharp.text.pdf)
  • has this someting to do with iText V5 - > V7 and is the tutorial maybe a bit out of date ?
  • are these classes only available in the Java libraries, and not in the .NET port ?

Does anyone have an example of drawing stuff on a canvas using VB.NET - this would be very helpful!

Thanks.

2

There are 2 best solutions below

4
On BEST ANSWER

To clarify further:

  • iText 5 .NET is nicknamed iTextSharp because of historical reasons that are beyond the scope of a Stack Overflow question.
  • iText 7 .NET doesn't have a nickname because we (iText Software) want to emphasize that it is exactly the same product as iText 7 Java, just for a different platform.

The tutorial you found is not out of date, on the contrary, it's the most recent one. It's the iTextSharp you got from NuGet that is out of date.

If you read the description on NuGet.org then you will clearly see that iTextSharp is the old version: https://www.nuget.org/packages/iTextSharp

We have two currently supported versions: iText 5 and iText 7. Both are available under AGPL and Commercial license.

iText 5 is a one solution library that is complex, but well documented to help you create your solutions.

iText 7 is a complete re-write of iText 5, allowing you to choose your adventure with add-ons, all based on a simple, modular code structure that is easy to use and well documented.

and

iTextSharp is the .NET port of iText 5.

If this wasn't clear enough for you (and it obviously wasn't), then I would really, really appreciate your feedback on how we can improve the description on NuGet.org.

0
On

Make sure you have the right NuGet packages on your system. To try this out, create an empty project and include NuGet packages

  • iText7 by iText Software v 7.0.4

The jumpstart tutorial was written for iText7, so it make sense you'd need that specific version. iText7 is a complete re-write of iText5. So you might indeed find several classes missing if you try to run the samples against the iText5 library.