We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Support on html to word conversion

hi,

We are using ASPOSE to convert a Word Document to HTML for editing.Again the edited document is convereted from HTML to Word using Aspose Libraries.Our Word Document has images in it.

We are facing an issue ,while converting from WORD to HTML.The issue is we are getting an Empty Page .So we have investigated the problem and found that ASPOSE ie generating the below code while converting from WORD to HTML,we suspect this could be the problem .So can you please provide us details about why the beow code is getting generated and the importance of it.We have removed the below code and checked ,it worked fine.Please provide your feedback on this ASAP as we have a delivery shortly.


 
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAANgCAYAAABqZOvtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAd+SURBVHhe7dKxDQAgDMTA7L90GOIKFMn0foHN7PEzx++/PeB3wQpUAA30hVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAF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VghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOnC/wAIHzncyCgnDcAAAAAElFTkSuQmCC"
width="48" height="864" alt="" style="margin-left: -50.4pt; margin-top: 0pt;
position: absolute; z-index: -65533" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAQiCAYAAACBVSwBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVGhD7dCBAAAAAMOg+VMf5IVQYcCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAgZeBASUyAAFBQLhxAAAAAElFTkSuQmCC"
width="2" height="1058" alt="" style="margin-left: 468pt; margin-top: 0pt; position: absolute;
z-index: -65534" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAQiCAYAAACBVSwBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVGhD7dCBAAAAAMOg+VMf5IVQYcCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAgZeBASUyAAFBQLhxAAAAAElFTkSuQmCC"
width="2" height="1058" alt="" style="margin-left: -7.2pt; margin-top: 0pt; position: absolute;
z-index: -65535" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAQiCAYAAACBVSwBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVGhD7dCBAAAAAMOg+VMf5IVQYcCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAgZeBASUyAAFBQLhxAAAAAElFTkSuQmCC"
width="2" height="1058" alt="" style="margin-left: -3.6pt; margin-top: 0pt; position: absolute;
z-index: -65536" />


 
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAANgCAYAAABqZOvtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAd+SURBVHhe7dKxDQAgDMTA7L90GOIKFMn0foHN7PEzx++/PeB3wQpUAA30hVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMV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QAVQIOMVYIU4UAEUyHgFWCEOVAAFMl4BVogDFUCBjFeAFeJABVAg4xVghThQARTIeAVYIQ5UAAUyXgFWiAMVQIGMV4AV4kAFUCDjFWCFOFABFMh4BVghDlQABTJeAVaIAxVAgYxXgBXiQAVQIOMVYIU4UAEUyHgFWCEOnC/wAIHzncyCgnDcAAAAAElFTkSuQmCC"
width="48" height="864" alt="" style="margin-left: -50.4pt; margin-top: 0pt;
position: absolute; z-index: -65533" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAQiCAYAAACBVSwBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVGhD7dCBAAAAAMOg+VMf5IVQYcCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAgZeBASUyAAFBQLhxAAAAAElFTkSuQmCC"
width="2" height="1058" alt="" style="margin-left: 468pt; margin-top: 0pt; position: absolute;
z-index: -65534" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAQiCAYAAACBVSwBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVGhD7dCBAAAAAMOg+VMf5IVQYcCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAgZeBASUyAAFBQLhxAAAAAElFTkSuQmCC"
width="2" height="1058" alt="" style="margin-left: -7.2pt; margin-top: 0pt; position: absolute;
z-index: -65535" />
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAQiCAYAAACBVSwBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABASURBVGhD7dCBAAAAAMOg+VMf5IVQYcCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgwYMCAgZeBASUyAAFBQLhxAAAAAElFTkSuQmCC"
width="2" height="1058" alt="" style="margin-left: -3.6pt; margin-top: 0pt; position: absolute;
z-index: -65536" />

Hi
Santhosh,


Thanks for your inquiry. Could you please attach your input Word document you are getting problems with here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

Hi,

Please find the word document. Please let us know the code fix(if any),below is the code snippet which we used.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

SAMPLE CODE FOR CONVERTING FROM WORD TO HTML

Aspose.Words.License license = new Aspose.Words.License();

license.SetLicense(("C:\\TCMS.IMAGING\\FormTemplates\\AsposeLicenses\\Aspose.Words.lic"));

Uri uri = new Uri(strFileName);

string filename = uri.LocalPath;

//Stream stream = File.OpenRead(Server.MapPath(filename));

Document doc = new Document(Server.MapPath(filename));

Aspose.Words.StyleCollection styles = doc.Styles;

doc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;

doc.ViewOptions.ViewType = ViewType.PageLayout;

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

////// Iterate through all paragraphs

foreach (Paragraph para in paragraphs)

{

//para.ParagraphFormat.PageBreakBefore = false;

// Check all runs in the paragraph for page breaks and remove them.

if (para.Range.Text == "\r")

{

para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

para.ParagraphFormat.ClearFormatting();

}

}

//NodeCollection sec = doc.GetChildNodes(NodeType.Section, true);

//////// Iterate through all paragraphs

//foreach (Section para in sec)

//{

// //para.ParagraphFormat.PageBreakBefore = false;

// // Check all runs in the paragraph for page breaks and remove them.

// doc.Sections.Remove(para);

//}

HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);

//Location to save images

options.ImagesFolder = "D:\\TCMS.IMAGING\\20120127\\";

options.ImagesFolderAlias = "D:\\TCMS.IMAGING\\20120127\\";

options.ExportTextInputFormFieldAsText = true;

options.ExportImagesAsBase64 = true;

options.ExportDocumentProperties = true;

options.ScaleImageToShapeSize = false;

options.ExportPageSetup = false;

options.ExportXhtmlTransitional = false;

options.ExportHeadersFootersMode = ExportHeadersFootersMode.PerSection;

options.DocumentSplitCriteria = DocumentSplitCriteria.None;

doc.Save(Server.MapPath(filename) + ".html", options);

// FileStream fstream = new FileStream(Server.MapPath(filename), FileMode.Open, FileAccess.Read);

StreamReader sr = new StreamReader(Server.MapPath(filename) + ".html");

string strValue = sr.ReadToEnd();

input.Text = strValue;

sr.Close();

sr.Dispose();

Hi
Santhosh,


Thanks for your inquiry. First of all, please note that when HtmlSaveOptions.ExportImagesAsBase64 property is set to true image data is exported directly on the img elements and separate files are not created. Please try turning this feature on/off and observe the generated HTML output.
Santhosh:
We are facing an issue ,while converting from WORD to HTML.The issue is we are getting an Empty Page
I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v11.0.0 and let us know your findings then.

I hope, this will help.

Best Regards,

Hi,

Thanks for your response.


After converting from HTML to Word,While saving the word document we are loosing the fonts/alignments ,so can you suggest us the code we need at add ,to resolve the issue

Please find the original doc and generated doc as attachments

1)Merge_RejectResponseTemplate4914300--original doc

2)GeneratedGenerated-Saved Doc

SAVE CODE

========================START==========================

MemoryStream storeStream = new MemoryStream();StreamWriter sw = new StreamWriter(storeStream);sw.Write(input.Text);sw.Flush();//char[] dataarray = getChar();//MemoryStream storeStream = new MemoryStream();//StreamWriter sw = new StreamWriter(storeStream);//sw.Write(dataarray);//sw.Flush();Aspose.Words.Document doc = new Aspose.Words.Document(storeStream);NodeCollection sections = doc.GetChildNodes(NodeType.Paragraph, true);foreach (Paragraph para in sections){// Check all runs in the paragraph for page breaks and remove them.if ((para.Range.Text).Trim() == string.Empty){para.ParagraphFormat.Alignment = ParagraphAlignment.Center;}}string strFileName = Convert.ToString(ViewState["FILENAME"]);Uri uri = new Uri(strFileName);string filename = uri.LocalPath;//Document doc = new Document(storeStream);doc.Save(Server.MapPath(filename), SaveFormat.Doc);storeStream.Close();storeStream.Dispose();sw.Close();sw.Dispose();MemoryStream storeStream = new MemoryStream();StreamWriter sw = new StreamWriter(storeStream);sw.Write(input.Text);sw.Flush();//char[] dataarray = getChar();//MemoryStream storeStream = new MemoryStream();//StreamWriter sw = new StreamWriter(storeStream);//sw.Write(dataarray);//sw.Flush();Aspose.Words.Document doc = new Aspose.Words.Document(storeStream);NodeCollection sections = doc.GetChildNodes(NodeType.Paragraph, true);foreach (Paragraph para in sections){// Check all runs in the paragraph for page breaks and remove them.if ((para.Range.Text).Trim() == string.Empty){para.ParagraphFormat.Alignment = ParagraphAlignment.Center;}}string strFileName = Convert.ToString(ViewState["FILENAME"]);Uri uri = new Uri(strFileName);string filename = uri.LocalPath;//Document doc = new Document(storeStream);doc.Save(Server.MapPath(filename), SaveFormat.Doc);storeStream.Close();storeStream.Dispose();sw.Close();sw.Dispose();-=====================END===============

Thanks

Santhosh

Hi
Santhosh,


Thanks for your inquiry. What I understand, you’re trying to save some HTML document to DOC format. If this is found to be the case, please attach here this HTML file for further investigation. In case, I misunderstood, could you please explain your problem in more detail?

Best Regards,