Adding AWT Image to PDF with Color : AWT Image « PDF RTF « Java

Adding AWT Image to PDF with Color

Adding AWT Image to PDF with Color
import java.awt.Color;
import java.awt.Toolkit;

import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class AddingAWTImageColorPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddingAWTImageColorPDF.pdf"));;
      PdfContentByte cb = writer.getDirectContent();
      java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage("logo.png");

      Image image = Image.getInstance(awtImage, new Color(0x00, 0x00, 0xFF), true);
      image.setAbsolutePosition(100, 500);
    } catch (Exception e) {

       1,748 k)

Related examples in the same category

1.Adding AWT Image to PDFAdding AWT Image to PDF