Free Support Forum - aspose.com

Headers / Footers lost When Converting from RTF to Doc

Hi!

When I try to convert a doc from RTF to DOC, the headers and footers are lost. Very simply, I am doing this:

Document doc = new Document("myrtffile.rft");

doc.Save("mydocfile.doc", SaveFormat.Doc);

Is there a fix in the works for this? Or can I have a workaround?

Thanks in advance for your help! :-)

Rich

BTW - I am using aspose.words 7.0.0.0. This happens with any RTF file I create with MS Word that has a header and footer.

Thanks!
Rich

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

As a temporary workaround, you can try using the following code:

// Open source document.

Document doc = new Document(@"Test001\in.rtf");

// Loop through all sections.

foreach (Section section in doc.Sections)

{

// Create list, where we will temporary store headers/footers.

ArrayList hfList = new ArrayList();

foreach (HeaderFooter headerFooter in section.HeadersFooters)

{

// Create copy of the header/footer.

HeaderFooter hfNew = new HeaderFooter(doc, headerFooter.HeaderFooterType);

// Copy all content from old header footer.

foreach (Node node in headerFooter.ChildNodes)

hfNew.AppendChild(node);

hfList.Add(hfNew);

}

// Remove old headers/footes.

section.HeadersFooters.Clear();

// Add new headers/footers.

foreach (HeaderFooter headerFooter in hfList)

section.HeadersFooters.Add(headerFooter);

}

// Save output document.

doc.Save(@"Test001\out.doc");

Hope this helps.

Best regards.

Thanks for your help. I can now copy headers and footers.

The issues you have found earlier (filed as 11088) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(75)