WordPad: "Picture" = "End of File"?

There's this annoying bug in WordPad in XP that I'm surprised I couldn't find very much about. But it's hit me on more than one machine (and I never seem to remember it until after it happens, of course).

Whenever I create a document and I paste a picture into it from the clipboard (usually copied out of Paint, as that's a convenient way for me to get an image on the clipboard in a hurry), the picture and any text after it is not saved with the document.

This time, naturally, it happened to be on my set of release notes for a product release, where I happened to add a picture to the beginning of the document. Entire document, gone.

It seems to be a function of WordPad itself adding the picture to the document. If I open a document that already has a picture (e.g. by creating a document with a picture in Word and saving it as RTF), I can do just about anything to the document, including cutting and pasting the picture to other locations. It's just the act of initially adding that picture to the document that makes WordPad stop processing.

Why use RTF at all? Well, RTF is a very convenient format for creating simple text files that have a little bit of formatting. They're also extremely portable — whereas Word documents (or documents saved in "Word-compatible" formats) can sometimes display oddly in different versions of whatever you're using to view them, there's so little in an RTF that you're almost always guaranteed you'll see the text and its formatting as it was intended, without any attempt to dictate margins or other unimportant stuff. It makes it very handy for distributing a simple document to clients that look decent, don't require any extra software to display (they will at least have WordPad, if not something bigger; I can't guarantee they'll even have a PDF viewer, or a DOC viewer for that matter), yet has just enough formatting to be "professional" (as opposed to plain text). It can also be embedded in a Windows Installer, which is part of my goal here.

Why use WordPad when I have Word installed? Well, my goal is to have a very simple file, without extra garbage or formatting codes. Creating a particular file in Word, which includes a single 24x24 picture, and saving it as RTF resulted in a 53kB document, which, if you look at in a plain text editor, you can see over 7k of format codes defining (among other things) fonts that aren't even used in the document, before the first line of actual text. Merely opening that file in WordPad and saving it (which has the effect of stripping out all the garbage, taking it down to the bare necessities) results in an identically-formatted file that is 15kB. (Unfortunately, it doesn't replace Word's "smart quotes" with standard ones.)

I remember taking a Word 2.0 document, opening it up in Word 6.0, and saving it, with no changes, and noticing the file size balloon to four times its original. So the inefficiency in Word's file formatting comes as no surprise.

Workaround: I played with this a bit before publishing this post, and I figured out the solution. If you go to the Edit menu and select "Paste Special…", you can paste the image as a Bitmap, a Picture (Metafile), or a Device Independent Bitmap. It seems the default, Bitmap, is the one that causes the problem, as selecting either other option works fine. Of course, the Edit menu is the only place this "Paste Special…" option is available, as right-click only shows "Paste" and Ctrl-V/Shift-Ins use the default option.

I tested this in Vista and the public beta of Windows 7. Copying a picture out of Paint in Vista, the default Paste in WordPad worked just fine. Paste Special showed "Unidentified", "Picture (Metafile)", and "Device Independent Bitmap", and all of these worked. I was able to get "Bitmap" as an option in Paste Special by taking a screenshot, but that, too, worked without a problem. Windows 7 had almost the exact same results, except that Paste Special with what was copied from Paint actually listed "Paint Picture" as the first option. Everything else worked pretty much the same (except for having to deal with that annoying "ribbon" toolbar in both Paint and WordPad).

So, I guess, the fix for being able to paste bitmaps in WordPad without losing the rest of the document, is to upgrade to the latest version of Windows.


Spencer said...

And again, even if there is a workaround, let's note that it's a silly thing for the default pasting functionality to misbehave so spectacularly.

Also, my CAPTCHA was Sompsine, which I think would be a pretty decent name for a rock band.

bookladydavina said...

I think I'd rather do a complex and annoying multi-step work around that required standing on my head and sacrificing a chicken before I'd willingly upgrade to Vista, thank you very much.....