Everything you want to do (page margins, borders, page breaks, font
style and size) is available in HTML via CSS or is a settable feature in
Word. Word follows CSS conventions as if it were Internet Explorer.
You can open up straight HTML in Word and print it out as if you had
rendered it in a browser. In my opinion and experience, the option to go
with is COM and Word.
Check out the code I've attached. This code is the almost the exact same
thing I use in my shop to print out 3000+ pages per week.
- Matt Small
// Write a full HTML page to a plain .htm text file
<cffile action="write" file="output.htm" output="#page#">
// Connect to or open a word object
<cftry>
<cfobject action="CONNECT" class="Word.Application" name="objWord"
type="COM">
<cfcatch>
<cfobject action="CREATE" class="Word.Application" name="objWord"
type="COM">
</cfcatch>
</cftry>
<cftry>
<cfscript>
// Grab the list of documents and from that, open output.htm
objDoc = objWord.Documents;
newDoc = objDoc.open("output.htm");
// This is page set up for orientation and page margins
po = newDoc.PageSetup;
po.Orientation = 1; // 1 is for landscape, 0 for portrait
po.TopMargin = 36; // 72 points = 1 inch
po.BottomMargin = 36;
po.LeftMargin = 36;
po.RightMargin = 36;
// This section sets up page numbering. All this information is
available
// at http://msdn.microsoft.com <http://msdn.microsoft.com/> and
http://www.cfcomet.com
objSecs = newDoc.Sections;
objSec1 = objSecs.Item(1);
objSec1Headers = objSec1.Headers;
objSec1Header1 = objSec1Headers.Item(1);
objRange = objSec1Header1.Range;
// Set the paragraph format
// Values for alignment are {0=Left,1=Center,2=Right,3=Justify}
objParaFormat = objRange.ParagraphFormat;
objParaFormat.Alignment = 2;
// Set a right-tab at 6 inches
// Tab positions are in points, where 72 points = 1 inch
// Arguments to the TabStops.Add function:
// Position: 6 inches * 72 points/inch = 432 points
// Alignment: values include {0=Left,1=Center,2=Right}
objTabStops = objParaFormat.TabStops;
objTabStops.ClearAll();
objTabStops.Add(432,2);
objRange.Select();
objSelection = objWord.Selection;
objFont = objSelection.Font;
objFont.Name = "Arial";
objFont.Size = 10;
// Insert the page number
// Page number is field type 33
// Story is unit type 6
objRange.Collapse(0);
objFields = objRange.Fields;
objFields.Add(objRange,33);
</cfscript>
// You should only send one job at a time to a printer.
// Otherwise, print jobs may be directed to the wrong printer
<cflock name="printout" type="exclusive" timeout="300">
// The printer variables are the paths to the network or local printers
// and are found on the windows printer test page
<cfscript>
switch (form.printer) {
case 1: {objWord.ActivePrinter = "#printer_princess#"; break;}
case 2: {objWord.ActivePrinter = "#printer_lana#"; break;}
case 3: {objWord.ActivePrinter = "#printer_3#"; break;}
case 4: {objWord.ActivePrinter = "#printer_4#"; break;}
case 5: {objWord.ActivePrinter = "#printer_5#"; break;}}
newDoc.PrintOut();
</cfscript>
</cflock>
<cfscript>
newDoc.Close();
objWord.Quit();
</cfscript>
<cfcatch>
<cfscript>
newDoc.Close();
objWord.Quit();
</cfscript>
<cfrethrow>
</cfcatch>
</cftry>
</cflock>
-----Original Message-----
From: Costas Piliotis [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 4:03 PM
To: CF-Talk
Subject: RE: Re: Mail Merge Options
Why not use crystal reports? You can export to word if needed... Works
really well... Just don't call them through the cfreport tag.
-----Original Message-----
From: Howie Hamlin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 6:38 AM
To: CF-Talk
Subject: Re: Re: Mail Merge Options
You may want to look into something like Active PDF. You can definitely
make reports with that and they would be portable to any OS that
supports
acrobat.
HTH,
Howie
----- Original Message -----
From: "Ian Skinner" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, April 29, 2002 11:26 PM
Subject: Re: Re: Mail Merge Options
> No, the letters do not have to be Word Format, we can choose any
> format the fulfills the requirement.
>
> The requirement is a batch of highly formatted form letters output to
> a printer local to the client machine. This formatting will need to
> include page margins, borders, page breaks, font style and size and
> other features. All of which I do not know how to include in a
> straight plain text or HTML formatted document, particularly page
> breaks to separate one form letter from the other.
>
> We are open to any suggestion.
>
> Thanks Again.
>
> Ian Skinner
> (916) 338-0728
> ilsweb+AEA-pacbell.net
> www.ilsweb.com
>
>
> Date: Mon, 29 Apr 2002 17:20:31 -0400
> From: +ACI-Howie Hamlin+ACI- +ADw-howie+AEA-coolfusion.com+AD4-
> Subject: Re: Mail Merge Options
> Message-ID:
> +ADw-0a4401c1efc3+ACQ-b1768400+ACQ-0201010a+AEA-hoot.com+AD4-
>
> Do the letters have to be in Word format or could they be plain text
> or HTML as well?
>
> Regards,
>
> --
> Howie Hamlin - inFusion Project Manager
> On-Line Data Solutions, Inc. - www.CoolFusion.com - 631-737-4668 x101
> inFusion Mail Server (iMS) - The Award-winning, Intelligent
> Mail Server
> +AD4APgA+- Find out how iMS Stacks up to the competition:
> http://www.coolfusion.com/imssecomparison.cfm
>
>
>
> FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
> Archives: http://www.mail-archive.com/[email protected]/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
>
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists