This is what we’re expecting as well, but didn’t happen.
Please can you try the samples sent in first thread, as probably i didn’t express myself clear.
just create an empty console app and add this snippet in the Main:
Document docHead;
string docToAppend = @"NewDoc.odt";
Document document = new Document(@"CurrentDoc.odt");
DocumentBuilder builder = new DocumentBuilder(document);
docHead = new Document(docToAppend);
builder.MoveToDocumentStart();
builder.CurrentSection.HeadersFooters.LinkToPrevious(false);
builder.InsertDocument(docHead, ImportFormatMode.KeepSourceFormatting);
builder.InsertBreak(BreakType.SectionBreakNewPage);
document.Save(@"TestHead.odt");
@Remus87 When you use InsertDocument method, section from the original document is not preserved, only content is inserted into the current section in the document. In your case it would be more correct to use AppendDocument method to preserve section from the source document. For example see the following code:
Document dst = new Document(@"C:\Temp\NewDoc.docx");
Document src = new Document(@"C:\Temp\CurrentDoc.odt");
dst.AppendDocument(src, ImportFormatMode.KeepSourceFormatting);
dst.Save(@"C:\Temp\out.docx");
In this case the first page does not have header, and the following pages have header.
Thanks, that seems to work. However, have to do several modifications now to accompany the AppendDocument method, and is quite not working as expected when appending another document at the end of the document.
Previously (when was using InsertDocument) was able to move through the document easily by making use of the Move method of the DocumentBuilder class and copy the documents at the desired location on the current document.
So now when trying to append Footer.doc as example at the end of the dst document it will inherit it’s headers from last section also. To replicate that just add the below in continuation to your last code supplied:
//also added this instance as a fix to not inherit headers style from dst document
ImportFormatOptions importFormat = new ImportFormatOptions();
importFormat.IgnoreHeaderFooter = false;
Document docFoot = new Document(@"C:\Temp\FOOTER.DOC");
dst.AppendDocument(docFoot, ImportFormatMode.KeepSourceFormatting);
Thanks, solved the previous issue correctly the snippet provided.
However, the client spotted another fault, this time on the style preservation: the Indent of text is not accurate (see the IndentIssue.docx with screenshot for difference)
in continuation of the code just append the previous document to this one from the folder supplied -> “A newdoc May 15.docx” so that this new document to come first docNewDoc.AppendDocument(document, ImportFormatMode.KeepSourceFormatting, importFormat);
Also tried to add page numbering on the final document following aspose sample as below but couldn’t
DocumentBuilder builder = new DocumentBuilder(docNewDoc);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.Write("Page ");
builder.InsertField("PAGE", "");
builder.Write(" of ");
builder.InsertField("NUMPAGES", "");
I cannot reproduce the problem with indentation on my side. I have used an empty document as a target document and appended the document you have attached. Could you please also attach your target document here for testing? We will check the issue and provide you more information. Also, please try using the following code:
is already attached on the first Sample folder from first message on this thread. File name -> CurrentDoc.odt
Document dst = new Document(@"C:\Temp\A newdoc May 15.docx");
Document src = new Document(@"C:\Temp\CurrentDoc.odt");
dst.AppendDocument(src, ImportFormatMode.KeepSourceFormatting);
Can replicate in both directions. Either append dst to src, or the other way around.
@Remus87
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-26001
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@Remus87 Unfortunately, there are no news regarding the issue yet. I have asked the responsible developer to take a look at it shortly. Please accept our apologies for your inconvenience.
You can obtain Paid Support Services if you need support on a priority basis.
We’ve tested and looks ok on MS Word. When opening with LibreOffice there’s still a minor indentation issue.
I’ve attached the necessary files to display the issue.
For now that should be ok, but maybe will be good to fix that also in the near future.
@Remus87
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-26592
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.