Using iText to create PDF and Annotations can be hard at first. I learned it the hard way since it was my first time to take a crack into doing it. While this post does not provide the source code on how to do it (sorry, I am not giving it away for free but you can buy it from me), here are some tips to help get you started.

1) The coordinate system in PDF is different
I created an annotation layer in PDF.JS so I could create annotations on top of PDF pages. Naturally, I stored the annotation coordinates to keep track of its location. When I used the annotation data to create a PDF embedded with them, I was surprised that the positions were incorrect. It turned out the y-coordinate is actually from bottom to top instead of top to bottom. No worries though, you can create a function that will return the bottom-to-top y-coordinate based on your top-to-bottom y-coordinate. Bruno Lowagie actually provided a function for that in some StackOverflow forum post.

2) No SVG library for C# that iText can use to use as images
I created both a Java and C# implementation for this and I could not find a C# library that could let me use an SVG image in iText. Java has a 3rd party library for that though.

3) Do not get confused with Adobe Acrobat and Adobe Acrobat Pro’s comment window
Yes, I have to admit I got confused at first when I set all my comments to locked and read-only I thought that it did not work because the look and feel in Acrobat and Acrobat Pro looks different. If you have Acrobat Pro or Acrobat X, better use that to see your output PDF generated by iText as it gives a better presentation on how you set your annotations’ properties like locked and read-only.

4) If you used PDF.JS to save annotations and export them using iText, the page dimensions are different.
I created annotations using PDF.JS and its page dimensions at scale 100% are different in an actual PDF page when viewed in Acrobat. In order to position them correctly in a physical PDF file, create a function that will return the x and y coordinate of a physical PDF page’s dimension based from the PDF.JS annotation position and its page dimension. Sounds confusing? Here is a sample pseudo function with parameters.

5) Search in Google on how to create annotations using iText
Most annotation types (rectangle, circle, line, arrow, free text, free hand drawing, text underline, text strike-through, text highlight, stamp, icons) that my web application featured have samples provided by Bruno Lowagie in his iText documentation website and StackOverflow forum.

6) Converting to Java, C# or vice-versa is not hard
Once you implemented code using Java or C#, it is not hard to do considering most if not all of the classes are the same. It is just a matter of renaming some naming conventions on properties and methods

vincplusplusWritten by Kerasiotis Vasileios. What if programming languages were real persons like you and me? What if they were parts of families and had relations and affairs? Have you ever thought of going to a supermarket and Visual Basic was the young woman waiting in the line in front of you?

C++ is 45 years old teacher at the Devel City university, following his father’s steps to become as respected as he is. He loves his father so much that tried to continue his work and knowledge. Being a younger man than C though, made him a much more friendly guy, in the means of approach, than his father. He works as a teacher in the Devel City university and his students have a love and hate affair with him.

C++ often lets his students choose their way in the learning process since he follows a different way of teaching approach than his father used to. His students love him because he lets them work in their own way but sometimes they fear his inheritance of C.

Most of his followers admire his wide range of knowledge that mixes C’s knowledge with knowledge gained through his life.
There are also a lot of people that criticise him of being so wide. Most of the time they talk about him as a direct descendant of C that has adopted all of his fathers disadvantages and added some more to it.

C++ has spent many years to get rid some of his fathers bad habits and never does things not needed. He prefers to put as much effort as needed to do the job right and never bloats things. This is why his projects are much more targeted than his fathers.

charliec

Written by Kerasiotis Vasileios. What if programming languages were real persons like you and me? What if they were parts of families and had relations and affairs? Have you ever thought of going to a supermarket and Visual Basic was the young woman waiting in the line in front of you?

Charlie C is a 70 years old man that knows a lot. Perhaps too proud to reveal what he knows and sometimes too cryptic. He is a very strict person that follows his way of doing things and nothing seems possible to change his mind. In the past he was known as one of the strictest teachers in the Devel City university.

C can make you happy or disappoint you so much that, you want go for one of his sons or daughters. It
depends on how much you try to learn his ways. The more you try the more he gives you.

C has been the main builder behind large projects like the Linuxious stadium and other large scaled buildings that we all use. He still works as a freelancer engineer and has involved in many other projects. Even at his age and with a lot of competition mainly from his son C++, C is still the choice of many companies to do
things in Devel City.

C has 3 daughters :

  • Perl
  • Java and
  • C#

and one son, C++.

Related Posts Plugin for WordPress, Blogger...