2012年12月3日月曜日

Getting RawData From Image File

import java.io.FileOutputStream;
import java.io.RandomAccessFile;

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

public class RawDataFromImageFilePDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("RawDataFromImageFilePDF.pdf"));
document.open();

RandomAccessFile rf = new RandomAccessFile("logo.png", "r");
int size = (int) rf.length();
byte imext[] = new byte[size];
rf.readFully(imext);
rf.close();

Image img1 = Image.getInstance(imext);
img1.setAbsolutePosition(50, 500);
document.add(img1);

} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}

0 件のコメント:

コメントを投稿