Page width issue when appending landscape content

I’m using AppendDocument to append a Word document which is in landscape layout and a PDF which is also in landscape layout (after converting the PDF to DOCX).
My issue is that the page width of the landscape section form the first word document is different from the page width of the inserted PDF document (the page width with the PDF content is smaller).
Also the content of the PDF content is cut of on the right hand side (see page with “Title Lorem Ipsum Dolor”)
How can I have the same page width for both inserted documents?
Thanks,
SetContentControlTest.zip (3.5 MB)
thomas

@tpalmie

Please remove the following comment code form your application to get the desired output.

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(strFileToInsert2);
int posOfLastBackslash = strFileToInsert2.LastIndexOf(@"\");
string strDocxFileName = strFileToInsert2.Substring(0, posOfLastBackslash) + @"\_" + strFileToInsert2.Substring(posOfLastBackslash + 1);
strDocxFileName = strDocxFileName.Replace(".pdf", ".docx");
// Save the file into MS document format
pdfDocument.Save(strDocxFileName, Aspose.Pdf.SaveFormat.DocX);
documentBuilder.InsertBreak(BreakType.SectionBreakNewPage);
Aspose.Words.Document insertDoc2 = new Aspose.Words.Document(strDocxFileName);

/* // set the page setup of the inserted content
insertDoc2.FirstSection.PageSetup.PaperSize = pageSetup.PaperSize;
insertDoc2.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
insertDoc2.FirstSection.PageSetup.LeftMargin = pageSetup.LeftMargin;
insertDoc2.FirstSection.PageSetup.RightMargin = pageSetup.RightMargin;
insertDoc2.FirstSection.PageSetup.TopMargin = pageSetup.TopMargin;
insertDoc2.FirstSection.PageSetup.BottomMargin = pageSetup.BottomMargin;*/

documentBuilder.MoveToDocumentEnd(); 

Please note that PageSetup class represents the page setup properties of a section. its object contains all the page setup attributes of a section (left margin, bottom margin, paper size, and so on) as properties. You are facing this issue because the page size is set different form the source document (PDF). You need to set the page size of appended document according to your requirement.

Thank you Tahir.
Removing this section of the code fixes the issue that the appended document from the PDF is not cut off on the right hand side.
However, the page width of the previously appended word document in landscape mode and the page width of the appended PDF is still different. That’s why I was setting the margins on the insertDoc2.
How can I have the same page width for both: the appended document from the word doc AND the appended document from the PDF?
best regards,
thomas

@tpalmie

In your case, you need to check the PageSetup properties of section such as paper size, page width and height and set them for inserted document if required.

The previously appended word document in landscape mode has paper size ‘A4’ and the appended PDF file has custom size. If you set the paper size of second document to ‘A4’, the content will cut from right side due to page width. So, you need to set the page width according to your requirement.