Pattern Matrix for an image : Image « PDF « Java Tutorial

import java.awt.Color;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.CMYKColor;
import com.lowagie.text.pdf.PatternColor;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPatternPainter;
import com.lowagie.text.pdf.PdfShading;
import com.lowagie.text.pdf.PdfShadingPattern;
import com.lowagie.text.pdf.PdfSpotColor;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.ShadingColor;
import com.lowagie.text.pdf.SpotColor;

public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));;
    PdfContentByte cb = writer.getDirectContent();

    PdfSpotColor psc_cmyk = new PdfSpotColor("iTextSpotColorCMYK", 0.25f, new CMYKColor(0.3f, .9f,
        .3f, .1f));
    SpotColor sc_cmyk = new SpotColor(psc_cmyk);

    Image img = Image.getInstance("dog.jpg");
    PdfPatternPainter img_pattern = cb.createPattern(img.scaledWidth(), img.scaledHeight(), img
        .scaledWidth(), img.scaledHeight());
    img_pattern.addImage(img, img.scaledWidth(), 0f, 0f, img.scaledHeight(), 0f, 0f);
    img_pattern.setPatternMatrix(1f, 0f, 0f, 1f, 60f, 60f);

    PatternColor img_color = new PatternColor(img_pattern);
    document.add(new Paragraph("This is a paragraph painted using an image pattern", new Font(
       Font.HELVETICA, 24, Font.BOLD, img_color)));

29.35.1.Add image to an existing Pdf document
29.35.2.Image transition
29.35.3.Create chunk from Image
29.35.4.Scale Absolute
29.35.5.Scale Percent
29.35.6.Scale Percent: 100, 50
29.35.7.Image Wrapping
29.35.8.Image Alignment
29.35.9.Image Mask
29.35.10.Convert java.awt.Image to com.lowagie.text.Image
29.35.11.Black and White
29.35.12.Red and Yellow
29.35.13.Rotate 30 degrees
29.35.14.Get Image height and width
29.35.15.Rotate 45 degreesRotate 45 degrees
29.35.16.Image Absolute Position
29.35.17.Pattern Matrix for an image