Hi
Thanks for
your request. Sure, you can convert text documents to images using
Aspose.Words. Here you can find a code that shows how you can load TXT
documents into Document object:
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-load-plain-text-txt-files.html
Then, you can convert the Document to PNG and make it
grayscale:
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.saving.imagesaveoptions.imagecolormode.html
Code will look like the following:
[Test]
public void Test001()
{
TxtToGrayScalePng(@"Test001\in.txt", @"Test001\");
}
/// <summary>
///
Converts txt document to png images.
/// </summary>
private static void
TxtToGrayScalePng(string inputFileName, string outputDirectory)
{
// Load TXT document into Document object.
// This object will help us generate the document.
DocumentBuilder builder = new
DocumentBuilder();
// You might need to specify a different encoding depending
on your plain text files.
using (StreamReader
reader = new StreamReader(inputFileName,
Encoding.UTF8))
{
// Read plain text "lines" and convert them into
paragraphs in the document.
string line = null;
while ((line = reader.ReadLine()) != null)
{
builder.Writeln(line);
}
}
// Save each page of the document as grayscale PNG.
ImageSaveOptions opt = new
ImageSaveOptions(SaveFormat.Png);
opt.PageCount = 1;
opt.ImageColorMode
= ImageColorMode.Grayscale;
for (int i = 0; i
< builder.Document.PageCount; i++)
{
opt.PageIndex =
i;
string outputFileName = string.Format("page_{0}.png", i);
builder.Document.Save(Path.Combine(outputDirectory,
outputFileName), opt);
}
}
You can use
code suggested here you insert your existing images into Document object:
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-convert-an-image-to-pdf.html
And save the document’s pages as grayscale PNG as shown in
the previous code example.
Hope this
helps.
Best regards,
Alexey Noskov
Developer/Technical Support
Aspose Auckland Team