Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Sane printing from TextEdit Apps
I don't know if this is obvious to everyone or not, but I didn't see it specifically posted as a hint, and I just discovered it myself (after many years) so I thought it might be worth posting.

If you print from TextEdit, the margins used in the printout are based on how you've scaled your document window. So, if you've made your document very wide, for instance, TextEdit will attempt to use the wide document's borders as the print margins, resulting in scaled text and a lower-than-expected page count. Conversely, if you make your document very narrow, TextEdit will try to use the narrower margins and print many pages at a larger font size. (You can see this behavior by simply creating a TextEdit document with some text, scaling the document window to something very wide, printing and then previewing the print rather than actually printing it. Then repeat this with the same document scaled to something extremely narrow. See the difference?)

This has driven me crazy for some time, as I use TextEdit for a lot of my writing needs these days. (I dunno, I just like it.)

The solution can be found under the "Format" menu. Before you print, select "Wrap to Page" from the menu (or press command-shift-w). TextEdit will present your document to you with normalized margins, and will then print your document using those margins. It will even show page breaks. Very handy! Of course, to switch back to the default TextEdit view, just select "Wrap to Window" from the Format menu (or press command-shift-w again).
    •    
  • Currently 3.50 / 5
  You rated: 3 / 5 (6 votes cast)
 
[12,862 views]  

Sane printing from TextEdit | 6 comments | Create New Account
Click here to return to the 'Sane printing from TextEdit' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Even better
Authored by: jecwobble on Jan 10, '07 09:17:11AM
You will likely find even the Wrap to Page to be too restrictive. Follow Cameroon's instuctions near the bottom of the comments of this hint to adjust the margin size to your liking: http://www.macosxhints.com/article.php?story=20040428213001127

[ Reply to This | # ]
Even better
Authored by: blinkintosser on May 06, '10 10:37:19PM
For what it is worth, here is an AppleScript to change the margins in the frontmost TextEdit document. Save it to ~/Library/Scripts/Applications/TextEdit to have it appear in your scripts menu (if you have it enabled). The code is potentially dangerousóit could devour your homeworkóbut it keeps your original document (temporarily) at $TMPDIR./remarginizer.rtf should you need to recover it.

-------------------------------------------------------------
-- AppleScript: Modify margins in frontmost TextEdit document
-------------------------------------------------------------
property sTempFilePosixPath : "$TMPDIR./remarginizer.rtf"

-- RTF margins are measured internally in twips (1/20th of a point, 1/1440")
property iUnitConversion : 1440 -- adjust to express your margins in an alternate unit: 1440 for inches, 20 for points, 567 for points
property lMargins : {0.5, 0.5, 0.5, 0.5} -- left, right, top, bottom
property lRtfControlWords : {"\\margl", "\\margr", "\\margt", "\\margb"}

main()
on main()
	if name of document 1 of application "TextEdit" does not end with ".RTF" then -- trivial test to see if doc is rtf and has been saved
		display alert "Cannot Resize Margins" message "You must save the document as rich text (RTF) before resizing margins."
	else
		-- get margin values from user
		set AppleScript's text item delimiters to ", "
		copy lMargins as string to sMargins
		set AppleScript's text item delimiters to ","
		copy text returned of (display dialog "Enter new margins as:" & return & "<left>, <right>, <top>, <bottom>" default answer sMargins) to sMargins
		repeat with i from 1 to 4
			set item i of lMargins to ((text item i of sMargins) as number) -- save back to property as new default
		end repeat
		set AppleScript's text item delimiters to ""
		
		-- compile margin list into a string of RTF control words
		copy "" to sRtfMargins
		repeat with i from 1 to 4
			copy sRtfMargins & item i of lRtfControlWords & ((item i of lMargins) * iUnitConversion as integer) to sRtfMargins
		end repeat
		
		tell application "TextEdit"
			copy path of document 1 to sRtfDocPosixPath
			close document 1
		end tell
		
		-- copy RTF file to $TMPDIR, then write modified RTF back to original (rather than move) to preserve inode, attributes, etc.
		copy "/bin/cp " & quoteText(sRtfDocPosixPath) & " " & quoteText(sTempFilePosixPath) to sCmdCopy
		copy escapeText(" && /usr/bin/awk '{while ($0 ~ /\\marg[rtb][0-9]*/) {sub(/\\marg[rtb][0-9]*/, \"\", $0)};{sub(/\\margl[0-9]*/, " & quoteText(sRtfMargins) & ", $0); print}}'") to sCmdAwk
		copy " < " & quoteText(sTempFilePosixPath) & " > " & quoteText(sRtfDocPosixPath) to sCmdRedirect
		copy " && /bin/rm " & quoteText(sTempFilePosixPath) to sCmdDelete
		do shell script (sCmdCopy & sCmdAwk & sCmdRedirect) -- left off "& sCmdDelete" from line above so original doc is preserved in temp file for emergency recovery; add at own risk
		
		tell application "TextEdit" to open sRtfDocPosixPath
	end if
end main

on escapeText(sText)
	set AppleScript's text item delimiters to "\\"
	copy every text item of sText to sTextList
	set AppleScript's text item delimiters to "\\\\"
	copy sTextList as string to sText
	set AppleScript's text item delimiters to ""
	return sText
end escapeText

on quoteText(sText)
	return "\"" & sText & "\""
end quoteText


[ Reply to This | # ]
Sane printing from TextEdit
Authored by: thehyperone on Jan 10, '07 01:48:17PM
I read the whole aforementioned thread to it's completion and can't believe how much work everyone is going through to change a document's margin. Editing the source code and recompiling an entire application just to change a preference? Editing raw RTF source code to create templates? Just as bad. You're all starting to sound like you work for Microsoft.

In TextEdit, choose Page Setup from the File menu. Under Settings:, choose Custom Paper Size. Click the new button and it'll allow you to change the paper size as well as set all four margins independently. You can create quite a few margin-presets and reuse them to your heart's content.

Use this in conjunction with the original hint to set your margins.

[ Reply to This | # ]

Sane printing from TextEdit
Authored by: krusty76 on Jan 10, '07 02:12:05PM

Um, I've tried this "simple" solution many times in the past. I just verified on 10.4.8 ... and setting the margins via Page Setup... are completely ignored by TextEdit. Go ahead and try it. It's an exercise in futility.



[ Reply to This | # ]
Sane printing from TextEdit
Authored by: boredzo on Jan 10, '07 08:28:43PM

This has driven me crazy for some time, as I use TextEdit for a lot of my writing needs these days. (I dunno, I just like it.)

No shame in that. TextEdit is a very powerful word processor. Be proud. :)



[ Reply to This | # ]
Set defaults
Authored by: tidjj on Jan 11, '07 03:39:57PM

I can't see the goal of this behavior...
What I did immediately after reading this was to test, of course.
And immediately after testing was to check TextEdit preferences. A "Wrap to Page" checkbox makes TextEdit default to the right thing.



[ Reply to This | # ]