import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document.compress = false;
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
cb.setLineWidth(3);
cb.moveTo(40, 480);
cb.lineTo(320, 480);
cb.stroke();
cb.setLineDash(6, 0);
cb.moveTo(40, 450);
cb.lineTo(320, 450);
cb.stroke();
float[] dash1 = { 10, 5, 5, 5, 20 };
cb.setLineDash(dash1, 5);
cb.moveTo(40, 440);
cb.lineTo(320, 440);
cb.stroke();
float[] dash2 = { 9, 6, 0, 6 };
cb.setLineCap(PdfContentByte.LINE_CAP_ROUND);
cb.setLineDash(dash2, 0);
cb.moveTo(40, 430);
cb.lineTo(320, 430);
cb.stroke();
cb.restoreState();
document.close();
}
}
|