I have some generic code we use to merge rtf documents into a final document. its based on code that you guys sent me after a previous bug.
attached are the two documents, if you create a blank doc, append the worksheet.rtf and then append the privacy.rtf, it fails to insert a page break between the two documents, is there any thing I can do ?
can you clarify what is a section ? Is it a document ? Is there a way that sections are created in other ways ?
This fix means we are ending up with page breaks in the middle of documents, not just at the end.
Yes, a Document can have multiple Sections. In your case, you can set SectionStart.NewPage flag for the Sections inside Source/Inserted Documents only.
Document doc1 = new Document("D:\\temp\\Docs\\worksheet.rtf");
Document doc2 = new Document("D:\\temp\\Docs\\privacy.rtf");
foreach (Section section in doc1.Sections)
section.PageSetup.SectionStart = SectionStart.NewPage;
foreach (Section section in doc2.Sections)
section.PageSetup.SectionStart = SectionStart.NewPage;
Document TheDoc = new Document();
TheDoc.RemoveAllChildren();
TheDoc.AppendDocument(doc1, ImportFormatMode.KeepSourceFormatting);
TheDoc.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);
foreach (Section section in TheDoc.Sections)
{
if (section.HeadersFooters.Count == 0)
{
PageSetup pageSetup = section.PageSetup;
pageSetup.FooterDistance = 0;
pageSetup.HeaderDistance = 0;
}
section.HeadersFooters.LinkToPrevious(false);
}
TheDoc.Save("D:\\temp\\Docs\\18.9.rtf");
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.