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

MS WORD

    Sponsored Links

    Next

  • 1. where do I find the :find & replace when I need to edit in word
    i Have just started with Vista and have not been able to find the replace feature and find when I am trying to edit in Word can anyone tell me how to locate it and the how to's Thank you.
  • 2. How to outline object
    In Word 2007 how do i draw a box around a date in a calendar template ?
  • 3. Printing problem in word
    I get a thick black vertical line at the right side of the paper when a print a document that contains a picture. If a remove the picture the line disappears. exampel text | text | picture | text | text | The line is at the very right side on the paper. -- molle
  • 4. Formatting problem in WORD 2007
    I edit a quarterly fraternal publication. One of the office staff listed the names of the deceased members for a booklet (28 pages) to be handed out at the Convention. I, in the past, have gotten these names from the computer in the office later for inclusion in my quarterly publication. I did the same this year but something is drastically different in the list. There are NO formatting marks with the exception of the dots indicating spaces between names and one final paragraph mark at the very end. No paragraph marks, no manual line breaks, nothing! I turn the "formatting" on and off and all that changes are the dots between words. The format paragraph function decreased spaces between about half of the lines in the list and the rest remain with more than a single space between lines. Since I can't see the indicators I do not know what I've got. It is probably a template thing but I don't have the smarts to fix it. HELP!
  • 5. inserting a check box inside a word document

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
rtf-file?

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

K.reg...
D

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>
[DllImportAttribute("gdiplus.dll")]
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;

try
{
_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
_graphics.ReleaseHdc(_hdc);
}

// 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,
EmfToWmfBitsFlags.EmfToWmfBitsFlagsDefault);

// 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)
{
_rtf.Append(String.F

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

     fr.open()

Next 

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 76 guest