Margin not being saved in conversion from HTML to .DOC


#1

I am using an older version of aspose.word (2.1) and I have the following problem:

I have documents I read from .doc into HTML format and display in a Web textbox. The source indicates that there is a margin-left:252pt style on a P tag. When saved, the margin is saved as 0pt.

Will a newer version fix that? Will it require any upgrade cost?


#2

Hi,

Yes, please upgrade to the latest version of the component. If you purchased the license file before January 22, 2005, you should order the new license as described here:

http://www.aspose.com/wiki/default.aspx/Aspose.Corporate/OldOrderLicensingQuestions.html

Otherwise, no additional steps are required. If you continue experiencing the problem, please let us know and attach the problematic document to your post here.


#3

Attached are samples. The aspose_lindenBefore (.doc and .html) are before I resave, the aspose_lindenAfter (.doc and .html) show the .doc and .html AFTER they have been saved through aspose.words latest version. Note that everything is left flush in the After document and html.


#4

I tried to open your xxxBefore documents and save them to different formats. The indentation has been preserved. Please post your code which produces incorrect result (xxxAfter).


#5

Here is the code. I am opening an existing document, and then clearing the main contents (so that I preserve the header/footer).

Aspose.Words.License lic=new Aspose.Words.License();
lic.SetLicense(Page.MapPath("license/aspose.word.lic"));
// OLD CODE, OLD VERSION
// Word.SetLicense(Page.MapPath("license/aspose.word.lic"),this);
Aspose.Words.Word word=new Aspose.Words.Word();
// Open Oegiginal Document
Aspose.Words.Document doc=new Aspose.Words.Document(this.strOriginalDocumentFilename);
try {
byte[] buffer=System.Text.Encoding.ASCII.GetBytes(this.FreeTextBox1.Text);
System.IO.MemoryStream ms=new MemoryStream(buffer);
Aspose.Words.Section sec=doc.Sections[0]; sec.ClearContent();
// OLD CODE, OLD VERSION
// doc.Sections[0].ClearStory(Aspose.Words.StoryType.MainTextStory);
Aspose.Words.DocumentBuilder db=new DocumentBuilder(doc);
// Insert HTML into existing document, to preserve header/footer...
db.InsertHtml(this.FreeTextBox1.Text);
doc.Save(strNewFilename,Aspose.Words.SaveFormat.FormatDocument);
} catch (Exception Ex) {
Response.Write(Ex.ToString());
this.FreeTextBox1.Text="Document Not Found - Exception: " + Ex.ToString(); failedSave=true;
} finally {
doc=null;
}


#6

Again, when I replace this.FreeTextBox1.Text with HTML read from your source document, the resulting document does keep all formatting including the indentation.

Please make sure that the HTML string passed to the InsertHtml method is correct, i.e. does contain proper paragraph margin. If nothing helps, we however must reproduce your issue to address. It would be great if you could zip and attach the part of your project which produces incorrect document. Is it possible?


#7

Hmm. I cannot duplicate it either in a simple case. Obviously, something strange is happening…