not printed layer : Layer « PDF « Java Tutorial






import java.io.FileOutputStream;
import java.util.ArrayList;

import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.ColumnText;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfLayer;
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"));
    writer.setPdfVersion(PdfWriter.VERSION_1_5);

    document.open();

    PdfContentByte cb = writer.getDirectContent();

    PdfLayer not_printed = new PdfLayer("not printed", writer);
    not_printed.setOnPanel(false);
    not_printed.setPrint("Print", false);
    cb.beginLayer(not_printed);
    ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase("PRINT THIS PAGE"), 300, 700,
        90);
    cb.endLayer();
    
    document.close();
  }
}








29.70.Layer
29.70.1.Using Layer
29.70.2.Text on layer
29.70.3.Create PdfLayer
29.70.4.Show hide text with layer
29.70.5.Nested Layers
29.70.6.Grouped layers
29.70.7.Radio Group
29.70.8.not printed layer