Java/PDF RTF/Image Manipulation — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 05:58, 1 июня 2010
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();
}
}
Getting RawData From Image File and Manipulation
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 RawDataFromImageFileAndManipulationPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("RawDataFromImageFileAndManipulationPDF.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();
for(int i=0;i<imext.length;i++){
imext[i]= (byte)(imext[i]+3);
}
Image img1 = Image.getInstance(100, 100, 3, 8, imext);
img1.setAbsolutePosition(200, 200);
document.add(img1);
} catch (Exception e) {
System.err.println(e.getMessage());
}
document.close();
}
}