Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/01/2010, 16:26
joseluisbz
 
Fecha de Ingreso: febrero-2007
Ubicación: Barranquilla, Colombia
Mensajes: 181
Antigüedad: 17 años, 2 meses
Puntos: 3
Respuesta: Insertar Imagen en archivo RTF usando Java Puro

http://puretech.paawak.com/2006/10/2...rtf-with-java/

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.swing.ImageIcon;

public class PictureReader {

public static void main(String[] args) {
String ImageName = "/images/WaterLilies.jpg";
InputStream imageIp = PictureReader.class.getResourceAsStream(ImageName) ;

ImageIcon icon = new ImageIcon(PictureReader.class.getResource(ImageNam e));

StringBuffer sb = new StringBuffer("{\rtf1\ansi\par\pard\plain");

sb.append("n{\*\shppict{\pict")
.append("\picw").append(icon.getIconWidth())
.append("\pich").append(icon.getIconHeight())
.append("\jpegblipn"); // for PNG images, use \pngblip

int count = 0;

while(true) {

try {
int i = imageIp.read();

if (i == -1) {
break;
}

String hexStr = Integer.toHexString(i);

if (hexStr.length() == 1) {
hexStr = "0" + hexStr;
}

count += 2;

sb.append(hexStr);

if (count == 64) {
count = 0;
sb.append("n");
}

} catch (IOException e) {
e.printStackTrace();
}

}

sb.append("}}n}n");

try {
FileOutputStream fos = new FileOutputStream("Pic.rtf");
fos.write(sb.toString().getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}

}

http://www.astahost.com/info.php/jav...file_t356.html

http://kickjava.com/src/com/lowagie/...Image.java.htm
__________________
Jose Luis Bernal Zambrano
Please response to:
[email protected]