QuadrilateralCollection Class
A collection of quadrilaterals that specify areas of a text markup or link annotation.
Declaration
public class QuadrilateralCollection extends TrackedObjectCollection<Quadrilateral>
Remarks
Call TextMarkupAnnotation.getQuads() and LinkAnnotation.getRegion() methods to access annotation areas.
The collection implements the java.util.List interface and does not accept null items. If you add or insert a null item or replace an item with null, the API throws an ArgumentNullException. If you pass an index outside the collection bounds, the API throws an ArgumentOutOfRangeException.
Refer to the following help topic for additional information: Text Markup Annotations.
Example: Highlight Multiple Lines of Text
The following code snippet highlights two lines of text on a page:
import java.io.*;
import java.nio.file.*;
import java.util.List;
import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
public class Main {
public static void main(String[] args) throws Exception {
try (PdfDocument document = new PdfDocument()) {
Page page = document.getPages().add(595, 842);
page.addTextFragment("First line of text", 50, 700);
page.addTextFragment("Second line of text", 50, 680);
Quadrilateral firstLine = new Quadrilateral(
new PointF(50, 714), new PointF(170, 714), new PointF(50, 698), new PointF(170, 698));
Quadrilateral secondLine = new Quadrilateral(
new PointF(50, 694), new PointF(180, 694), new PointF(50, 678), new PointF(180, 678));
TextMarkupAnnotation highlight = new TextMarkupAnnotation(List.of(firstLine, secondLine));
highlight.setType(TextMarkupAnnotationType.HIGHLIGHT);
highlight.setColor(PdfColor.getYellow());
page.getAnnotations().add(highlight);
Files.createDirectories(Path.of("output"));
try (OutputStream stream = Files.newOutputStream(Path.of("output", "Document.pdf"))) {
document.save(stream);
}
}
}
}
Inherited Members
Inheritance
Constructors
QuadrilateralCollection() Constructor
Initializes a new instance of the QuadrilateralCollection class.
Declaration
public QuadrilateralCollection()
QuadrilateralCollection(Iterable<Quadrilateral> quadrilaterals) Constructor
Initializes a new instance of the QuadrilateralCollection class with the specified quadrilaterals.
Declaration
public QuadrilateralCollection(Iterable<Quadrilateral> quadrilaterals)
Parameters
| Name | Type | Description |
|---|---|---|
| quadrilaterals | java.lang.Iterable<Quadrilateral> | Quadrilaterals to add to the collection. |
Exceptions
| Type | Description |
|---|---|
| ArgumentNullException | Thrown if the |
Methods
getSource() Method
Returns the internal collection that stores collection items.
Declaration
public QuadrilateralCollection getSource()
Returns
| Type | Description |
|---|---|
| com.devexpress.docs.pdf.internal.QuadrilateralCollection | The internal collection. |
Remarks
The getSource() method supports the internal infrastructure of the PDF Document API. Do not call the getSource() method in your code.