import java.awt.Color;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PatternColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPatternPainter;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfPatternPainter square = cb.createPattern(15, 15);
square.setColorFill(new Color(0xFF, 0xFF, 0x00));
square.setColorStroke(new Color(0xFF, 0x00, 0x00));
square.rectangle(5, 5, 5, 5);
square.fillStroke();
PatternColor squares = new PatternColor(square);
cb.setColorFill(squares);
cb.rectangle(36, 716, 72, 72);
cb.fillStroke();
document.close();
}
}
|