how to insert/embed a gif-file in a rtf-file?


    Sponsored Links


  • 1. How to open multiple instances of Word 2003?
    PanJack, To the best of my knowledge this behaviour was already in Word2002. Try "Tools", "Options", on the "view" tab there should be an option on your right which allows you to have multiple windows. Hope this helps Luc "PanJack" < XXXX@XXXXX.COM > schreef in bericht news:06a201c386ad$b70b2150$ XXXX@XXXXX.COM ... > Word 2003 makes a major change in window behavior from > Word XP. Word XP was "Document-centric"--each document > opened its own copy of Word, had its own menus and > toolbars, and could be moved to any area of the screen. > Word 2003 goes back to the mid-1990s style > of "Application-centric" word processing--each document > opens within the Word workspace. > > I often have multiple documents open and want the > flexibility of viewing them side by side but also > minimizing one or another document temporarily to view > the obscured windows beneath it. The "Application- > centric" behavior of Word 2003 makes this a pain. I also > frequently want to turn toolbars on in some open > documents but not in others. > > Is there any way to switch Word 2003 back to document- > centric mode? > > Thanks, > PanJack
  • 2. How do i change font to subscript?
    How do i change font to subscript to write out formulas? thanks
  • 3. reloading Word
    reformatted after virus; cannot load MS Word 2000 as I do not have hard jewel case, only the plastic liner with the product ID and bar code(Cert of Authority) but I can't find the CD-Key? 25 characters??? Word was originally installed on computer. How do I now use the currently worthless 7 discs of the Works Suite if all I have is the Certificate of Authority but not the hard case? Thanks
  • 4. Lock hidden
    How can I password protect certain parts of my document (words) from being viewed? So when emailing to a client they will be unable to view the particular item but can still view the document? I can change the words to pictures, charts, commments, or fields if need be. thank you in advance for any help you can provide,
  • 5. word document and switching printers
    We have a department that types documents in word and switches printers to the department they are typing the document for. When they switch to a HP4000 they get the document to print all of it. When they switch back to their hp4050 it only prints half of the documents. I have upgraded the print drivers and even set up the printers to local IP addresses. Any ideas.

how to insert/embed a gif-file in a rtf-file?

Postby dpe2001go » Sat, 03 Apr 2004 22:05:10 GMT

Hi there,

We have a program that generates a rtf-file (some 1.500 pages...) and
all of them should be signed. Problem: I'm not able to link/embed
(using insert | field) the signature-file (let's say: sign.gif), the
program works with its own templates (rtf), and I've been searching
and trying some things but after inserting, the filesize increases up
to 1,5 mb, and that's something that piece of software obviously
doesn't like. (the original 'template'/rtf is about 39 kb)

Is there a way to include/embed/... that boring sign.gif into the

All tips are welcome, as long as I don't have to copy-paste for a
thousand times!


RE: how to insert/embed a gif-file in a rtf-file?

Postby U2FjaGlu » Tue, 22 Jun 2004 10:46:02 GMT

ry following C# code to embed the image in an rtf doc, tell me if it works.

/// <summary>
/// Allows the x and y coordinates of metafile to be adjusted independently
/// </summary>
private const int MM_ANISOTROPIC = 8;

/// <summary>
/// Use the EmfToWmfBits function in the GDI+ specification to convert a
/// Enhanced Metafile to a Windows Metafile
/// </summary>
/// <param name="_hEmf">
/// A handle to the Enhanced Metafile to be converted
/// </param>
/// <param name="_bufferSize">
/// The size of the buffer used to store the Windows Metafile bits returned
/// </param>
/// <param name="_buffer">
/// An array of bytes used to hold the Windows Metafile bits returned
/// </param>
/// <param name="_mappingMode">
/// The mapping mode of the image. This control uses MM_ANISOTROPIC.
/// </param>
/// <param name="_flags">
/// Flags used to specify the format of the Windows Metafile returned
/// </param>
private static extern uint GdipEmfToWmfBits (IntPtr _hEmf, uint _bufferSize,
byte[] _buffer, int _mappingMode, EmfToWmfBitsFlags _flags);

/// <summary>
/// Wraps the image in an Enhanced Metafile by drawing the image onto the
/// graphics context, then converts the Enhanced Metafile to a Windows
/// Metafile, and finally appends the bits of the Windows Metafile in HEX
/// to a string and returns the string.
/// </summary>
/// <param name="_image"></param>
/// <returns>
/// A string containing the bits of a Windows Metafile in HEX
/// </returns>
private string GetRtfImage(Image _image)

StringBuilder _rtf = null;

// Used to store the enhanced metafile
MemoryStream _stream = null;

// Used to create the metafile and draw the image
Graphics _graphics = null;

// The enhanced metafile
Metafile _metaFile = null;

// Handle to the device context used to create the metafile
IntPtr _hdc;

_rtf = new StringBuilder();
_stream = new MemoryStream();

// Get a graphics context from the RichTextBox
using(_graphics = this.CreateGraphics())

// Get the device context from the graphics context
_hdc = _graphics.GetHdc();

// Create a new Enhanced Metafile from the device context
_metaFile = new Metafile(_stream, _hdc);

// Release the device context

// Get a graphics context from the Enhanced Metafile
using(_graphics = Graphics.FromImage(_metaFile))

// Draw the image on the Enhanced Metafile
_graphics.DrawImage(_image, new Rectangle(0, 0, _image.Width, _image.Height));


// Get the handle of the Enhanced Metafile
IntPtr _hEmf = _metaFile.GetHenhmetafile();

// A call to EmfToWmfBits with a null buffer return the size of the
// buffer need to store the WMF bits. Use this to get the buffer
// size.
uint _bufferSize = GdipEmfToWmfBits(_hEmf, 0, null, MM_ANISOTROPIC,

// Create an array to hold the bits
byte[] _buffer = new byte[_bufferSize];

// A call to EmfToWmfBits with a valid buffer copies the bits into the
// buffer an returns the number of bits in the WMF.
uint _convertedSize = GdipEmfToWmfBits(_hEmf, _bufferSize, _buffer, MM_ANISOTROPIC, EmfToWmfBitsFlags.EmfToWmfBitsFlagsDefault);

// Append the bits to the RTF string
for(int i = 0; i < _buffer.Length; ++i)

Similar Threads:

1.embedded file objects in rtf files

I am trying to save each embedded  file object in a rtf file.  I am able to 
get to the file object  but dont know what else to do since the OLEFormat 
doesn't have a save as method.  How can I go by on saving each file object to 
a directory? The majority of my embedded file objects are pdf file.  Here' s 
my code:

Dim oWord As Word.Application 

Dim oDoc As Word.Document

Dim fl As Word.InlineShape

Dim fr As Word.OLEFormat

oWord = New Word.Application

oWord.Visible = True

oWord.WindowState = WdWindowState.wdWindowStateMinimize

oDoc = oWord.Documents.Open(FileName)

For i = 1 To oDoc.InlineShapes.Count

     fl = oDoc.InlineShapes.Item(i)

     fr = fl.OLEFormat


End If

I use the open method just to make sure I reference the file object.

Please help!!!

Juan E. Garcia

2.RTF and GIF files

When haveing an rtf referencing a gif file (import command) under Windows 2000 / Word 2000 / Sv pack 3, Word doesn't display the gif graphics (and event not print)

When haveing the same under Win2000 / Word 2000 - the graphics are visible in Page Preview and on printouts

Thanks and kind regards
Stephan Gloo
Gloor Informatik

3.Insert RTF File... Disable "Conversion File" window

4.Embedded .jpeg and .gif files

I have a document which required the files to be embedded in the document as 
icons, in Word 2000. I understand that insert-->object is a bad way to go, so 
is there any other way to embed (no I can't link the files, they must be in 
the document), jpegs and gif files into a word 2000 document without their 
size increasing by a factor of 10+? I can embed Word and Pdf files without 
much of an increase in size. Also it seems when I try to embed .gif and .jpeg 
files, word sets the icon as the Word icon, not the jpeg/gif icon.
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

5.Embedded jpeg and Gif files increasing in size

Recently I tried to embed a .gif and .jpeg into a word document. I need to 
have the files embedded and showing as an icon. The only way I know how to 
embed a picture as an icon is by inserting it as an object. But when I do, 
the file size increases by a factor of 10!!! so a 500k jpeg on a blank Word 
2000 document makes the Word document size 5 megs. I tried this with a PDF, 
and had no such problems. How can I avoid increasing the Word document size 
by 10x, but still keep embedded pictures that look like icons?

J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

6. Smallest RTF file which can import or embed an image

7. MS Word 2000 and inserting .GIF files generated from MS Project 98

8. Can't insert GIF image with "Link to File"

Return to MS WORD


Who is online

Users browsing this forum: No registered users and 71 guest