hi steve,
it looks quite helpful, but how to do it in Java? i'm doing it in Java
marco
Steve Oney wrote:
>
> Here is a hack that I did to openjade.1.3 (http://openjade.sourceforge.net/)
> I don't know if it will help or not.
> bool RtfFOTBuilder::includePicture(const ExternalGraphicNIC &nic)
> {
> StringC filename;
> char fileNbuf[30];
> char fileCbuf[35];
> char scalex[35];
> char scaley[35];
> char picw[35];
> char pich[35];
> char picwgoal[35];
> char pichgoal[35];
> char x, y, *ptr;
> int buf;
> int ii = 1;
> FILE *inFile;
> FILE *inCFile;
> size_t i;
> if (systemIdFilename(nic.entitySystemId, filename)) {
> if(getenv("JADE_EMBED") != (char *)0) {
> for (i = 0; i < filename.size(); i++) {
> fileNbuf[i] = filename[i];
> }
> fileNbuf[i] = 0;
> if((ptr = strrchr(fileNbuf, '.')) == NULL){
> printf("ERROR: graphic file %s those not have extension\n",
> fileNbuf);
> exit(1);
> }
> ptr++;
> if(strcmp(ptr, "jpg") == 0) { os() <<
> "\r\n{\\pict\\jpegblip\r\n"; }
> else if (strcmp(ptr, "gif") == 0) { os() <<
> "\r\n{\\pict\\pngblip\r\n"; }
> else if (strcmp(ptr, "wmf") == 0) { os() <<
> "\r\n{\\pict\\wmetafile8"; }
> else {
> printf("ERROR:graphic file %s has a NONsupported extension\n",
> fileNbuf);
> exit(1);
> }
> strcpy(fileCbuf, "C.");
> strcat(fileCbuf, fileNbuf);
> if((inCFile = fopen((const char *)&fileCbuf[0], "r")) != NULL){
> // fscanf(inCFile, "%s %s %s %s %s %s", scalex, scaley, picw, pich,
> picwgoal, pichgoal);
> fscanf(inCFile, "%s %s", scalex, scaley);
> os() << "\\picscalex";
> os() << scalex;
> os() << "\\picscaley";
> os() << scaley;
> // os() << "\\picw";
> // os() << picw;
> // os() << "\\pich";
> // os() << pich;
> // os() << "\\picwgoal";
> // os() << picwgoal;
> // os() << "\\pichgoal";
> // os() << pichgoal;
> os() << "\r\n";
> fclose(inCFile);
> }
>
> if((inFile = fopen((const char *)&fileNbuf[0], "r")) == NULL){
> printf("ERROR:opening graphic file %s errno=%i\n", fileNbuf,
> errno);
> exit(1);
> }
> while((buf = fgetc(inFile)) != EOF){
> x = (buf & 0xF0) >> 4;
> y = (buf & 0x0F);
> x = ((x < 10) ? (x + 48) : (x + 87));
> os() << x;
> y = ((y < 10) ? (y + 48) : (y + 87));
> os() << y;
> if(!(ii++ % 78)){os() << "\r\n";}
> }
> fclose(inFile);
> os() << "\r\n}";
> } else {
> os() << "{\\field\\flddirty{\\*\\fldinst INCLUDEPICTURE \"";
> // FIXME non-ascii characters
> for (i = 0; i < filename.size(); i++) {
> if (filename[i] == '\\')
> os() << "\\\\\\\\";
> else
> os() << char(filename[i]);
> }
> os() << "\" }{\\fldrslt }}";
> }
> return 1;
> }
> return 0;
> }
>
> The part you may be interested in is:
>
> while((buf = fgetc(inFile)) != EOF){
> x = (buf & 0xF0) >> 4;
> y = (buf & 0x0F);
> x = ((x < 10) ? (x + 48) : (x + 87));
> os() << x;
> y = ((y < 10) ? (y + 48) : (y + 87));
> os() << y;
> if(!(ii++ % 78)){os() << "\r\n";}
> }
>
> you have to convert the binary image to 7bit
>
> Steven Oney
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: Kin-Yip Tsang [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 30, 2001 9:22 AM
> To: [EMAIL PROTECTED]
> Subject: Re: FO to RTF
>
> i'm also looking for it. i'm a student working on this RTF converter. do
> you know anything about OLE? i want to try embedding a bmp image into
> RTF to see if it works, but i've found there's something more than that.
> what i mean is there seems to be some more hex data apart from the
> proper bmp data. and i've spent the whole day looking for the
> documentation in microsoft.com but still can't find the OLE
> documentation.
>
> and the \par is also a problem. sometimes \par can't be applied to the
> end of some blocks, otherwise there'll be extra linefeeds, and i really
> don't know how to make the program very general.
>
> marco
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]