Good morning,
if I use the code mentioned below, when the document is divided into sections, a new blank page after page 98 will be created.
When I save this document as a PDF, another blank page appears after page 64
Document doc = new Document(@"C:\Temp\Test\0TS215pV01.docx");
Document DocClone = (Document)doc.Clone(false);
//docClone = (Document)doc.Clone(false);
DocClone.Sections.Clear();
doc.UpdatePageLayout();
ImportFormatOptions opt = new ImportFormatOptions() { KeepSourceNumbering = true };
for (int i = 0; i < doc.PageCount; i++)
{
Document page = doc.ExtractPages(i, 1);
DocClone.AppendDocument(page, ImportFormatMode.UseDestinationStyles, opt);
}
DocClone.Save(@"C:\Temp\Test\0TS215pV01_poroztrhani.docx");
DocClone.Save(@"C:\Temp\Test\0TS215pV01_poroztrhani.pdf", SaveFormat.Pdf);
You could take a look at it
Thank you in advance
0TS215pV01.docx (1.3 MB)
@benestom Could you please explain the goal of splitting document into page and rejoining it? Actually such processing does not guaranty to produce the same document layout as in the original document. The problem is that MS Word documents are flow documents by their nature and they do not have “page” concept. The classic example is the table that occupies several pages. If the table is split page page page it is mandatory to have a paragraph after each part the the table. Aspose.Words adds these paragraphs and this might push content down and broke the original document layout.
Yes, I divide the document into paragraphs, thereby simulating the division of documents into pages. Then I work on individual paragraphs.
Problem
- dividing the document and merging it again, for the table after page 98, one extra page is inserted there. (page with empty table 99page)
1ExtractPages add page with empty table
- If I save the folded document as a PDF, a page will be added below page 64 (empty page in pdf 65)
2page extension when generating pdf
@benestom As I have mentioned it is not always possible to preserve the original document layout after splitting the document into pages and rejoining the pages. Such manipulation changes the original document structure that expectedly will affect the document layout.