SourceCode/PROMS/DataLoader/WordDocument.cs
Rich 0e66393289 RichTextBox Processing
Output Config Info for Steps
2012-08-07 17:44:03 +00:00

111 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Volian.MSWord;
using LBWordLibrary;
using System.Threading;
namespace DataLoader
{
class WordDocument
{
private string _FileName;
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
private string _ASCII = null;
public string ASCII
{
get { return _ASCII; }
set { _ASCII = value; }
}
private float _DocLen = 1.0F;
public float DocLen
{
get { return _DocLen; }
set { _DocLen = value; }
}
private string _Stype;
/// <summary>
/// 16-bit's type[1] used the following codes to represent the respective lpi setting
///
/// char far typestr[] = "*pP46f7L";
///
/// char * far printtypes[] = {
/// "Compressed, 8 lines per inch",
/// "Elite, 6 lines per inch",
/// "Pica, 6 lines per inch",
/// "Default font, 4 Lines Per Inch",
/// "Default font, 6 Lines Per Inch",
/// "Compressed 6 LPI",
/// "Default font, 7 Lines Per Inch",
/// "Special Landscape, Elite, 6 lines per inch"
/// </summary>
public string Stype
{
get { return _Stype; }
set
{
_Stype = value;
if (_Stype != null)
{
if (_Stype != null)
{
// stype[1] == 'p' or 'P' or '6' 'f' or 'L' get spc = 6
if (_Stype[1] == '*') LPI = 8;
else if (_Stype[1] == '4') LPI = 4;
else if (_Stype[1] == '7') LPI = 7;
// if need landscape set too: bool landscape = (stype[1] == 'L');
}
}
}
}
private int _LPI = 6;
public int LPI
{
get { return _LPI; }
set { _LPI = value; }
}
private string _OutFileName;
public string OutFileName
{
get { return _OutFileName; }
set { _OutFileName = value; }
}
public WordDocument(string fileName, string stype, string outFileName)
{
FileName = fileName;
Stype = stype;
OutFileName = outFileName;
}
public void GetAsciiFromWord()
{
WordDoc myWordDoc = null;
try
{
myWordDoc = new WordDoc(FileName);
myWordDoc.SetLineSpacing(LPI);
try
{
DocLen = myWordDoc.Length;
}
catch (Exception ex1)
{
Console.WriteLine("{0} - {0}\r\n\r\n{1}", ex1.GetType().Name, ex1.Message);
}
ASCII = myWordDoc.MyWordDoc.Ascii;
myWordDoc.Save(OutFileName);
myWordDoc.Close();
Thread.Sleep(500);
}
catch (Exception ex)
{
Console.WriteLine("Could not get Ascii", ex);
WordDoc.CloseApp();
}
}
}
}