Convert long text file to a single html file in .NET using C#

Hi,
I’m using GroupDocs.Viewer to convert text files to html.
When the text file is very long, GroupDocs.Viewer split this document to several pages instead of one html per file (this also applies to xml, csv files).

How can I setup GroupDocs.Viewer to produce one page per file? I would like to have something like for Spreadsheets: SpreadsheetOptions.ForOnePagePerSheet()

Thanks,
Dariusz

@kamelwielki,

GroupDocs.Viewer doesn’t provide any built-in options to render text files into a single HTML page. However, we have logged it in our Issue Tracking System (ID: VIEWERNET-2219) to check if it is feasible to implement this feature. You can also merge the files manually as shown in the following code sample:

// filePath="sample.xml"
static void renderDocument(string filePath)
{
	string outputDirectory = "D:/output";
	outputDirectory = Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(filePath));
	if (!Directory.Exists(outputDirectory))
	{
		Directory.CreateDirectory(outputDirectory);
	}
	// The {0} will be replaced with current processing page number.
	string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");

	using (Viewer viewer = new Viewer(filePath))
	{
		HtmlViewOptions htmlOptions = HtmlViewOptions
			.ForEmbeddedResources(pageFilePathFormat);
		htmlOptions.RenderResponsive = true;
		viewer.View(htmlOptions);
	}
	// Combine files into a single HTML file
	combineFiles(outputDirectory);
}
public static void combineFiles(string folderPath)
{
	string[] inputFilePaths = Directory.GetFiles(folderPath, "*.html");
	using (var outputStream = File.Create(Path.Combine(folderPath, "combined_output.html")))
	{
		foreach (var inputFilePath in inputFilePaths)
		{
			using (var inputStream = File.OpenRead(inputFilePath))
			{
				inputStream.CopyTo(outputStream);
			}
		}
	}
}

Please see a sample Lorem ipsum file (150 paragraphs). GroupDocs.Viewer creates 28 html files from it. Why should I manually combine these 28 files? I just would like to receive one html file.

LoremIpsum.zip (22.4 KB)

@kamelwielki,

Thanks for sharing the sample file. We are currently investigating your scenario to render the text files into a single HTML. We shall get back to you as soon as we have any updates on your requested feature.

The issues you have found earlier (filed as VIEWERNET-2219) have been fixed in this update. This message was posted using Bugs notification tool by atirtahir3