Greetings, my company is actively evaluating the purchase of Spire.Office for .NET Site Enterprise Subscription.
We are looking at the capabilities for generating a Word Doc from HTML, and have come up with a few questions.
We are currently using the Document LoadHTML method, see below.
1) Even when using the Spire.Doc.Documents.XHTMLValidationType.None we receive errors when the HTML is not perfectly formatted. For example, an <Input> tag without a closing tag. Are there any guidelines for how to construct the HTML / CSS for the best compatibility with Spire.Doc?
2) Is there a way to have the document rendered in Landscape (currently it is in portrait)? The PageLayout event does not seem to fire.
3) Are there HTML tags / attributes which will help control where page breaks occur in the rendered PDF?
4) JavaScript tag content that is included in the body is rendered into the Word document at text. Is there any way to prevent this?
Thanks in advance.
private void buttonDoc_Click(object sender, EventArgs e) {
//Get an HTML Stream
string url = "http://localhost:50035";
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
System.IO.Stream webStream = response.GetResponseStream();
TextReader textReader = new StreamReader(webStream);
Document doc = new Document();
doc.PageLayout += doc_PageLayout;
doc.LoadHTML(textReader, Spire.Doc.Documents.XHTMLValidationType.None);
doc.SaveToFile(@"C:\SpireTest.docx");
DocViewer(@"C:\SpireTest.docx");
}
void doc_PageLayout(object sender, Spire.Doc.Documents.Rendering.PageLayoutEventArgs args) {
args.PageSetup.Orientation = Spire.Doc.Documents.PageOrientation.Landscape;
}
private void DocViewer(string fileName) {
try {
System.Diagnostics.Process.Start(fileName);
} catch { }
}