Java/PDF RTF/Draw

Материал из Java эксперт
Перейти к: навигация, поиск

Draw Cross

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfDestination;
import com.lowagie.text.pdf.PdfOutline;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
public class DrawCrossPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawCrossPDF.pdf"));
      writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      PdfTemplate template = cb.createTemplate(25, 25);
      template.moveTo(13, 0);
      template.lineTo(13, 25);
      template.moveTo(0, 13);
      template.lineTo(50, 13);
      template.stroke();
      cb.addTemplate(template, 380, 780);
      cb.addTemplate(template, 160, 480);
      cb.addTemplate(template, 450, 270);
      cb.addTemplate(template, 90, 90);
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}