ITextSharp add comments PDF

Source: Internet
Author: User

IText supports different types of annotations.

Text: You can add a small piece of text to a document. This text is not part of the document content and has a title and some text content.

Annotation a = new Annotation (
"Authors ",
"Maybe it's because I wanted to be an author myself that I wrote iText .");

External link: when using external links as comments, you must specify a rectangular area and a string (the string is the URL of the target to be linked) or a URL object. The following is a demonstration of using strings and URL objects.

Annotation annot = new Annotation (100f, 700f, 200f, 800f, new URL ("http://www.cmszs.com "));
Annotation annot = new Annotation (100f, 700f, 200f, 800f, "http://www.cmszs.com ");

External PDF file: when using a PDF file as a comment, you must specify a rectangular area and target PDF file, a page linked to the file, or a target defined in the Link PDF file. The example is as follows:

Annotation annot = new Annotation (100f, 700f, 200f, 800f, "otheration", "mark ");
Annotation annot = new Annotation (100f, 700f, 200f, 800f, "otheration", 2 );

Naming action: when using a naming action as a comment, you must specify a rectangular area and a naming action as a parameter. As shown below

Annotation annot = new Annotation (100f, 700f, 200f, 800f, PdfAction. FIRSTPAGE );

Application: when using an application as a comment, you must specify a rectangular area and an application name as the parameter, as shown below.

Annotation annot = new Annotation (300f, 700f, 400f, 800f, "C: // winnt/notepad.exe", null );

If you do not need to specify the comment location when adding a text comment, iText processes it internally and the comment will appear below the text you want to add the comment. Annotations of other types except text must specify the coordinates of a rectangle. In this example, we draw some squares and add comments to the square. Click here to view the results of this example.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.