use of com.itextpdf.layout.Canvas in project pdf-editor by Pdf-Creator.
the class PDFDocument method addRectangleWithImageItem.
public void addRectangleWithImageItem(ImageItem imageItem) throws MalformedURLException {
PdfCanvas canvas = new PdfCanvas(currentPage);
Rectangle rect = new Rectangle(imageItem.getX(), imageItem.getY(), imageItem.getW(), imageItem.getH());
canvas.setStrokeColor(imageItem.getRectangleStrokeColor()).setFillColor(imageItem.getRectangleFillColor()).rectangle(rect).fill().stroke();
ImageData data = ImageDataFactory.create(imageItem.getImagePath());
Image image = new Image(data);
image.setFixedPosition(imageItem.getX(), imageItem.getY());
image.scaleAbsolute(imageItem.getW(), imageItem.getH());
new Canvas(canvas, rect).add(image);
}
use of com.itextpdf.layout.Canvas in project pdf-editor by Pdf-Creator.
the class PDFDocument method addRectangleWithTextItem.
public void addRectangleWithTextItem(TextItem textItem) {
// creating canvas on current page
PdfCanvas canvas = new PdfCanvas(currentPage);
// creating rectangle on canvas
Rectangle rect = new Rectangle(textItem.getX(), textItem.getY(), textItem.getW(), textItem.getH());
// drawing rectangle
canvas.setStrokeColor(textItem.getRectangleStrokeColor()).setFillColor(textItem.getRectangleFillColor()).rectangle(rect).fill().stroke();
// adding text to rectangle;
Paragraph paragraph = new Paragraph(textItem.getText());
paragraph.setFontColor(textItem.getFontColor());
new Canvas(canvas, rect).add(paragraph);
}
Aggregations