/// <summary>
/// create a tiff file from a string for fax
/// </summary>
/// <param name="content">the text content</param>
/// <param name="wideCharacter">open wide character support?</param>
/// <param name="folderPath">the temporary folder path</param>
/// <returns>physical path of the tiff file</returns>
public static string CreateFaxFile(string content,bool wideCharacter,string folderPath)
{
int lineCount = 1;
int charWidth;
if(wideCharacter)
{
lineCount += (int)Math.Ceiling(content.Length / 30);
charWidth = 16;
}
else
{
lineCount += (int)Math.Ceiling(content.Length / 60);
charWidth = 8;
}
lineCount += content.Length - content.Replace("\n","").Length;
Bitmap img = new Bitmap(600,100 + lineCount * 20);
Graphics graphic = Graphics.FromImage(img);
Font font = new Font("Courier New",11);
SolidBrush brush = new SolidBrush(Color.Black);
char[] data = content.ToCharArray();
int offsetX = 0;
int offsetY = 0;
for(int i = 0;i < data.Length;i++)
{
string s = data[i].ToString();
graphic.DrawString(s,font,brush,60 + offsetX,50 + offsetY * 20);
offsetX += charWidth;
if(s == "\t")
offsetX += charWidth;
if(offsetX == 480 || s == "\n")
{
offsetX = 0;
offsetY += 1;
}
}
FaxServer server = new FaxServerClass();
server.Connect(""); // local server
FaxDoc doc = (FaxDoc)server.CreateDocument("faxFileName");
doc.xxx = xxx...
...
doc.Send();
server.Disconnect();