Java/PDF RTF/PostScript

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

Encapsulated PostScript

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfWriter;
public class EncapsulatedPostScript {
  public static void main(String[] args) {
      Document document = new Document(PageSize.A4, 50, 50, 50, 50);
      try {
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("EncapsulatedPostScript.pdf"));
        document.open();
        Image img = Image.getInstance("yourpsFile.ps");
        img.scalePercent(50);
        document.add(img);
        document.close();
      }
      catch (Exception de) {
        de.printStackTrace();
      }
  }
}