Java/PDF RTF/Spot Colors

Материал из Java эксперт
Версия от 05:59, 1 июня 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Spot Colors for Template

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.GrayColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.SpotColor;
public class SpotColorsForTemplatePDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsForTemplatePDF.pdf"));
      document.open();
      PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));
      PdfContentByte cb = writer.getDirectContent();
      
      PdfTemplate t = cb.createTemplate(500f, 500f);
      t.setColorStroke(new SpotColor(spc_g, .5f));
      t.setLineWidth(10f);
      t.rectangle(100, 10, 100, 100);
      t.stroke();
      cb.addTemplate(t, -1.0f, 0.00f, 0.00f, -1.0f, 550f, 550f);
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}





Spot Colors for Text

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.GrayColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.SpotColor;
public class SpotColorsForTextPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsForTextPDF.pdf"));
      document.open();
      PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));
      document.add(new Paragraph("text in color", new Font(Font.HELVETICA, 24, Font.NORMAL, new SpotColor(spc_g))));
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}





Spot Colors Gray

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.GrayColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfWriter;
public class SpotColorsGrayPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsGrayPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));
      cb.setColorStroke(spc_g, .5f);
      cb.setLineWidth(10f);
      cb.rectangle(100, 700, 100, 100);
      cb.stroke();
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}





Spot Colors with CMYKColor

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.CMYKColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfWriter;
public class SpotColorsPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f));
      cb.setColorStroke(spc_cmyk, .5f);
      cb.setLineWidth(10f);
      cb.rectangle(100, 700, 100, 100);
      cb.stroke();
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}





Spot Color Tint

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.GrayColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfWriter;
public class SpotColorsTintPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsTintPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));
      cb.setColorStroke(spc_g, .5f);
      cb.setLineWidth(10f);
      cb.setColorFill(spc_g, spc_g.getTint());
      cb.rectangle(100, 700, 100, 100);
      cb.fill();
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}





SpotColor with PdfContentByte

import java.awt.Color;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.CMYKColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfWriter;
public class SpotColorsspc_rgbPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsspc_rgbPDF.pdf"));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      PdfSpotColor spc_rgb = new PdfSpotColor("PANTONE 147", 0.9f, new Color(114, 94, 38));
      cb.setColorStroke(spc_rgb, .5f);
      cb.setLineWidth(10f);
      cb.rectangle(100, 700, 100, 100);
      cb.stroke();
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}