Aspose.Words Document.Save. Is there a way to clear cache between saves

Hello,

I have a situation where I want to save 2 copies of a document. If I have comments in a document, I will first save with those comments, then I want to save without the comments. The issue is that when I save the second time it includes the comments.

If I clear comments without saving first, I get the desired result without comments, but I do not get the document with comments as well.

Is there a way to reset this / clear cache before trying to save the same document a second time?

Here is a code snippet:

var doc = new Document("c:\\temp\\MyDocument.docx");
// I am using PdfSaveOptions for specific reason.
SaveOptions saveOptions = new PdfSaveOptions()
{
    SaveFormat = SaveFormat.Pdf
};
docToSave.Save("c:\\temp\\myOutPut_rev.pdf", saveOptions);
doc.GetChildNodes(NodeType.Comment, true).Clear();
docToSave.Save("c:\\temp\\myOutPut.pdf", saveOptions);

Thanks,
Charles

As a note, I was able to clone the document and save the clone with my desired results.

@ccuster68,

Please call the Document.UpdatePageLayout method before saving to PDF the second time (after clearing the comments). Hope, this helps.

Hi Awais,

That was what I needed.

Thank you