Section 2.2. Copying and Pasting Text


2.2. Copying and Pasting Text

If you're building Web sites as part of a team or for clients , your writers are likely to send you their copy in the form of word processing documents. If the text comes in a Microsoft Word document or Excel spreadsheet, you're lucky. Dreamweaver 8 includes commands for pasting text from these two types of files. If you're using Windows, you can even import those kinds of files directly into a Web page using File Import Word/Excel Document (see Section 2.2.6).

2.2.1. Simple Copy and Paste

For nonMicrosoft-spawned text, you can, of course, still simply copy and paste like generations of Web designers before you.

Open the document in whatever program created itWordPerfect, AppleWorks, your email program, or whatever. Select the text you want (by dragging through it, for example), or choose Edit Select All (Ctrl+A [ -A]) to highlight all text in the document. Then choose Edit Copy, or press Ctrl+C (-C), to copy it. Switch to Dreamweaver, click in the document window where you wish the text to go, and then choose Edit Paste (Ctrl+V [ -V]).

This routine pastes the text into place. Unfortunately, you lose all text formatting (font type, size , color , bold, italic, and so on) in the process, as shown in Figure 2-3.

Furthermore, you may find that pasted paragraphs are separated by line break characters , not standard carriage returns. Strangely enough, this means that when you paste in a series of paragraphs, Dreamweaver treats them as though they were one gargantuan paragraph. These line-break characters can pose problems when trying to format what you think is a single paragraph. To identify these line breaks, see the note on Section 2.1.3.


Tip: If you have to copy and paste text from other programs, there's a way to get paragraphs (and not just lines separated by the line-break character) when you paste into Dreamweaver: make sure whoever's typing up the original documents inserts an extra paragraph between each paragraph of text. Pressing Enter (or Return) twice at the end of a paragraph inserts an empty paragraph. When you copy and paste, Dreamweaver removes the empty paragraphs and pastes the text as regular paragraphs.
Figure 2-3. Usually when you copy from any program other than a Microsoft Office program (Word, Excel, and so on) as shown at top, and paste into Dreamweaver, as shown at bottom, all formatting is lost, and paragraph breaks are replaced by line breaks. The little icon that appears at the end of the first line at right represents the invisible line break.

2.2.2. Paste Special

Actually, the previous explanation isn't exactly true. Dreamweaver 8 has added some new text-pasting features, some of which it attempts to use whenever it pastes text. Dreamweaver 8 actually supports four different types of paste methods , ranging from plain text to highly formatted HTML:

  • Text only . This option is the most basic of all. Text is pasted without any formatting whatsoever. Even paragraphs and line breaks are ignored, so you end up with essentially one long sentence . Though you won't want this effect often, it can come in handy when you copy a long paragraph of text from an email program that's added unnecessary line breaks at the end of each line of email text.

  • Text with structure . Dreamweaver tries to preserve the structure of the text, including paragraphs, headers, bulleted lists, and so on. This option doesn't keep formatting applied to text, such as bold or italics. Most nonMicrosoft Office copied text is pasted using this method. In most cases, however, Dreamweaver ends up preserving only paragraphs and misses bulleted lists and headers.

  • Basic formatting . When pasting with basic formatting, Dreamweaver includes the same elements as the "Text with structure" option, but also includes text formatting such as bold, italics, and underlining. This is the method Dreamweaver uses when pasting Microsoft Word or Excel information, as described in the next section.

  • Full formatting . This option includes everything offered by Basic formatting, but also attempts to paste CSS information that can control the font size and color, paragraph margins, and more. Full formatting is available only when copying and pasting from Word or Excel (see Section 2.2.3).


Note: Note to Windows owners : You can copy an entire page of HTML from Firefox or Internet Explorer and paste it into Dreamweaver. Click inside a Web page, press Ctrl+A to select the entire page, and then press Ctrl+C to copy the HTML. Then, switch to Dreamweaver, click inside an empty page, and press Ctrl+V to paste. All the HTML is copied, and even graphics appear. This text comes in with "full formatting," but note that external style sheets (see Section 6.1.2) do not come along for the ride.

You can override Dreamweaver's default behavior and choose a different method for pasting by using the Paste Special command. Choose Edit Paste Special to open the Paste Special window (see Figure 2-4). Here, you can choose which of the four techniques you wish to use sort of. Youre limited to what Dreamweaver can paste. For nonMicrosoft Office products, you can only use the first two options the others are grayed outwhereas with text copied from Word or Excel, you can choose from any of the four.

Figure 2-4. The Paste Special command lets you paste text copied from other programs. If you want Dreamweaver to apply the same setting each time you use the Paste Special command, click the Paste Preferences button. This opens the Preferences window. Select whatever settingsBasic formatting, for examplethat you want Dreamweaver to apply every time you use the Paste Special command.

In general, Dreamweaver's default settings are a good place to start for text copied from most programs. For Word or Excel information, there are a few options worth considering, as described next.

2.2.3. Pasting Text from Word: The Basic Method

While text from other applications doesn't retain much beyond paragraph formatting when pasted into Dreamweaver, Dreamweaver 8 includes both basic and advanced methods of copying and pasting Word text. You can even paste spreadsheet information from Excel, complete with rows, columns , and cells .

Frequently, you'll just want to preserve basic formatting like bold or italic text, headlines, and bulleted lists. You won't need (and in most cases, won't want) more extravagant formatting like different fonts, colors, or margin settings. After all, you're the Web designer, and you'll use your own design senseand Dreamweaver's CSS-based formatting toolsto add beauty to basic text.

Pasting Word text works like any copy/paste action described in the previous section. Just select the text in Word, copy it, switch to Dreamweaver, and then choose Edit Paste to drop it into a Web page. You dont have to spend a lot of time reformatting the pasted text (see Figure 2-5), since many basic formatting options are preserved:

  • Any paragraphs formatted with Word's built-in Heading styles (Heading 1, Heading 2, and so on) get the HTML heading tags <h1> (or heading 1), <h2>, <title>, and so on.

  • Paragraphs remain paragraphsmost of the time. Actually, how Dreamweaver pastes paragraphs depends on both how the paragraphs are formatted in Word and the setting of the Paste Special window's "Clean up Word paragraph spacing" setting (see Figure 2-4). If this option is selected (which it is by default), paragraphs you paste from Word appear as one large paragraph with line break characters at the end of each paragraph. Not the best method. To get Dreamweaver to paste each paragraph as a paragraph, choose Edit Paste Special, turn off the "Clean up Word paragraph spacing checkbox, and then click OK.

    WORKAROUND WORKSHOP
    Pasting HTML

    Suppose you've copied some HTML code, maybe out of the Source view of an actual Web page in a Web browser, or from a "How to Write HTML" Web site. You'll notice that when you paste it into Dreamweaver, all the HTML tags appear in the document window, complete with brackets (< >) and other assorted messiness.

    Unfortunately, Dreamweaver 8 eliminated the very useful Paste HTML tool, which let you paste HTML code while in Design view. Now you have to go into Code view and paste the HTML directly into the page's code. Code view is discussed in depth on Section 9.2.

    By the way, you don't have to worry about any of this when copying and pasting within Dreamweaver. The regular Copy and Paste commands are smart enough to keep all the formattingand HTML tagswhen copying and pasting within a Dreamweaver document. (If you do want to just paste the text and ignore the Dreamweaver formatting, choose Edit Paste Special and select the "Text only option.)



    Tip: If the Word document you're copying from has an empty line between each paragraph (in other words, an empty paragraph generated by pressing the Enter key twice after each paragraph), then make sure you DO have the "Clean up Word paragraph spacing" setting checkbox turned on. This eliminates those extra empty paragraphs.
  • Bold and italic text maintain their look in Dreamweaver. (The actual HTML tags, however, can vary, as described on Section 3.3.2.)

  • Basic alignment options (left, right, and center) remain intact. Justified text, on the other hand, gets pasted as left-aligned text. (You can compensate for this small oversight by using the justified alignment option on the Property inspector, described on Section 3.1.4.)

  • Numbered lists come through as numbered lists in Dreamweaver (see Section 3.2) if you used Word's automatic numbered-list feature to create them.

  • If you use Word's built-in list-bulleting feature, you end up with a proper HTML bulleted list (see Section 3.2). However, if the bulleted list includes custom bullets like checkmarks or clown faces, Dreamweaverfor whatever bizarre reasoninterprets the list as basic paragraphs preceded by bullet characters. That is, you don't wind up with the proper HTML for a bulleted list (which involves the <ul> tag)you just get plain paragraphs preceded by a bullet text character. This bullet might get deleted, ruining the look of the list, but even worse , you can't then take advantage of CSS's list-formatting properties to change this bullet into a square, hollow circle, or even little graphics (as described on Section 6.7.6).

  • Graphics from Word documents get pasted as graphics. In fact, even if the original graphics aren't in a Web-ready format (if they're BMP, TIFF, or PICT files, for example), Dreamweaver converts them to either the GIF or JPEG formats understood by Web browsers. Dreamweaver even copies the files to your local site root and links them correctly to the page. (Chapter 5 covers images in depth.)


Note: There are a couple of caveats with this feature. First, you can't copy and paste more than 300 KB worth of text, so you have to transfer really long documents in pieces (or better yet, spread them out among multiple Web pages). And second, this feature works only with versions of Word later than Office 97 (for Windows) or Office 98 (for Mac).

2.2.4. Pasting Text with Word Formatting

If you simply must keep that three-inch-tall, orange-text, crazy-cartoon-like font, you can turn to the "Full Formatting" option of the Paste Special command. After copying text from Word and returning to Dreamweaver, choose Edit Paste Special or press Ctrl+Shift+V (-Shift-V). When the Paste Special window appears, choose the "Full Formatting" option and click OK. (If you want this to be the default setting, so that you always paste the full formatting from Word, turn on the "Use these settings" checkbox before clicking OK in the Paste Special window.)

Dreamweaver pastes the text with as much formatting as possible, including margins, fonts, and text colors and sizes (see Figure 2-5). Behind the scenes, Dreamweaver pastes the text and adds Cascading Style Sheet code that attempts to approximate the look of the text in Word.

Figure 2-5. Dreamweaver 8 lets you paste Word text (and graphics)like the contents of the Word file (top)into a Web page, while preserving basic formatting options like headlines, italics, paragraphs, and bold (bottom left). The Paste Special command lets you preserve more advanced formatting such as font faces, colors, sizes, and margins (bottom right). But this special treatment comes at a price: the file size of the page on the bottom right is about 10 percent larger than the one on the bottom left.

Unfortunately, all this extra code increases the document's file size and download time and can interfere with future formatting changes. What's worse, most of your visitors won't even be able to see some of this formattingsuch as uncommon font faces. For these reasons, use this feature with caution.

2.2.5. Pasting Excel Spreadsheet Information

Dreamweaver 8 also lets you paste information from Microsoft Excel. Options include a basic method, using the standard Ctrl+V ( -V) or Edit Paste, and a format-rich method, using the "Full Formatting option of the Paste Special window: choose Edit Paste Special (or press Ctrl+Shift+V [ -Shift-V]), choose Full Formatting from the Paste Special window, and click OK. Both methods paste spreadsheet information as an HTML table composed of cells, rows, and columns. (See Chapter 7 for more on tables.)

But unlike pasting from Word, the basic Paste command from Excel preserves no formatting: it doesn't even hang on to bold and italics.

The Full Formatting option, however, preserves advanced formatting like font, font size, text color, and cell background colors.

2.2.6. Importing Word and Excel Documents (Windows)

Windows fans can also import material directly from a Word or Excel file into any Dreamweaver document. Just place the cursor where you wish to insert the text or spreadsheet, and then choose File Import Word Document (or Excel Document). An Open file dialog box appears; find and double-click the Word or Excel document you wish to import.

Dreamweaver captures the information just as if you'd used Edit Paste. That is, for Word documents, Dreamweaver carries over basic formatting like bold, italics, headlines, and paragraphs, and imports and converts images. The importing process doesnt create style sheets or apply advanced formatting. For Excel documents, you get just an organized table of datano formatting.

GEM IN THE ROUGH
Clean Up Word

From Word, you can save any document as a Web page, essentially turning a Word doc into HTML. The drawback to this method is that Word produces hideous HTML code. One look at it, and you'd think that your cat fell asleep on the keyboard.

The explanation: So you will be able to reopen the document as a Word file when the time comes, Word injects reams of information that adds to the file size of the page. This is a particular problem with the latest versions of Word, which add loads of XML and Cascading Style Sheet information.

Fortunately, Dreamweaver's Clean Up Word HTML command can strip out most of that unnecessary code and produce leaner Web pages. To use it, open the Word HTML file just as you would any other Web page: by choosing File Open. Once the file is open, choose Commands Clean Up Word HTML.

The Clean Up Word HTML dialog box opens; Dreamweaver automatically detects whether the HTML was produced by Word 97/98 or Word 2000/2001/2002/X/XP, and then applies the appropriate rules for cleaning up the HTML.




Dreamweaver 8[c] The Missing Manual
Dreamweaver 8[c] The Missing Manual
ISBN: 596100566
EAN: N/A
Year: 2006
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net