inserting an image in an RTF file

inserting an image in an RTF file

am 25.09.2004 12:30:01 von John

Hi all,

I'm generating RTF files on the fly.
Thanks to the msdn rtf spec
(http://msdn.microsoft.com/library/default.asp?url=/library/ en-us/dnrtfspec/
html/rtfspec.asp), I could format my rtf.
Still, I can't find the way to display images in the rtf file !
This is what I tried :

$fp = @fopen("logo.jpg", "rb") ;
$ImageContent = @fread($fp, @filesize("logo.jpg") ) ;
echo "{\*\shppict {\pict \jpegblip $ImageContent}}" ;

When I open the rtf file in word I've got an error message : "Memory or not
enough disk space to end the operation".

Do you have any idea/solution ?
Thank you in advance,

--
john

Re: inserting an image in an RTF file

am 25.09.2004 15:15:33 von Janwillem Borleffs

John wrote:
> When I open the rtf file in word I've got an error message : "Memory
> or not enough disk space to end the operation".
>

You should use the \binN control, where N is the file size in bytes and \bin
that you are using binary instead of the default base64 encoded data:

$image = "image.jpg";
$data = file_get_contents($image);
$size = filesize($image);
.....
print "{\\*\\shppict{\\pict\\jpegblip\\bin$size $data}}";

Also notice that this example uses double backslashes. This is needed
because of the double quotes in order to print a literal backslash.


HTH;
JW

Re: inserting an image in an RTF file

am 25.09.2004 16:38:15 von John

> You should use the \binN control, where N is the file size in bytes and
\bin
> that you are using binary instead of the default base64 encoded data:
>
> $image = "image.jpg";
> $data = file_get_contents($image);
> $size = filesize($image);
> ....
> print "{\\*\\shppict{\\pict\\jpegblip\\bin$size $data}}";
>
> Also notice that this example uses double backslashes. This is needed
> because of the double quotes in order to print a literal backslash.
>
>
> HTH;
> JW

Thank you for your help !

--
John