Line Annotations in PDF SDK

Tutorials | Line Start and End · Annotation Styles · Line Annotations Fri. 02 Jun. 2023

Line annotation is one of the most commonly used annotation in PDFs. Line annotations give you the ability to draw attention to important points or objects in documents, by setting line types such as arrows, dashes, and so on. With the line annotation tool in ComPDFKit, creating perfect lines has never been easier.


Communicate with ComPDFKit team and free trial now!



Line Annotations: Line Start and End 


When drawing lines in ComPDFKit, you can set different styles for the line start and end, such as square, round, or arrowhead, line styles can be set to solid / dashed, and line length can also be set to a specific size.


There are some different line annotations which are created by PDF Reader Pro in the following picture, one line annotation with a square end and start, a set of line annotations with different lengths, and a dashed line annotation.   


different types of line annotations


To set the line annotations programmatically, it would not be as easy as clicking few buttons. But all the readers could obtain the ability to draw line annotations by integrating ComPDFKit. You could see the supported styles in the following part.  




The styles of ComPDFKit line start and end are shown below. It conforms to Adobe PDF specification. 


         - Square

         - Circle

         - Diamond

         - Arrow

         - None

Line Annotations: The Line


There are some predefined styles, such as solid or dashed, you can set the line style by CPDFLineAnnotation.setLineType. You can then choose one of the available line styles. Except for line styles, the line length is also an important part. You could decide how long the line is by setting the value of start point and end point. You will understand how to set line styles and line length programmatically in the following sample code.

Sample Code


The line annotation feature provides users with various line start & end and line styles to present in documents. Follow the sample code of Java to create a line annotation in your document. The details about this annotation are also shown below:


         - Line Start: None

         - Line End: OpenArrow

         - Line Length: 45 Characters

         - Line Style: Dotted


CPDFLineAnnotation lineAnnotation = (CPDFLineAnnotation) page.addAnnot(CPDFAnnotation.Type.LINE);
lineAnnotation.setLineType(CPDFLineAnnotation.LineType.LINETYPE_NONE, CPDFLineAnnotation.LineType.LINETYPE_ARROW);

PointF startPoint = new PointF(0,0);
PointF endPoint = new PointF(100,100);
lineAnnotation.setLinePoints(startPoint, endPoint);





Line annotations are extremely useful in markup information and ComPDFKit provides the easiest way to create and set your perfect and various line annotations, giving your apps the ability to quickly draw attention to important points or objects. 

Free trial our PDF SDK or contact ComPDFKit team for consulting line annotations or other PDF features like viewing, editing, annotating, converting, form filling, digital signing, redacting, comparing, measuring, etc.

Ready to Get Started?

Download our all-in-one ComPDFKit for free and run it to your project within minutes!