We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extra empty page only with header and footer

When I am building a word document with header and footer and in the content I am adding a table I am getting extra empty page only with header and footer

Hi Dudua,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document if you are using any.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS : Please ZIP and upload documents on Dropbox or any other file hosting service and share the download link here for us to test this scenario.

thanks for your quick response ,

in the zip you can find the output file
you can find the input file (templateLandscape.docx)
attaching a VS 2015 project console application you can just run it and you will see the issue

Hi Dudua,

Thanks for sharing the detail. The file size of output.zip is big. Could you please remove the DLL files from your application and share it again? Thanks for your cooperation.

Hi Dudua,

You are getting the expected output document. If you save the document to DOCX file format and check the last paragraph of document. It is on 3rd page. Please use following code snippet before the save method to get the desired output.

foreach (Section section in document.Sections)
{
    section.PageSetup.HeaderDistance = 0;
}
document.UpdatePageLayout();
document.Save(Context.Output, AsposeHelper.GetSaveFormat(Context.OutputFormat));

thanks if i am changing the data i have the same issue ,
you can download the data file and update it in the project and the issue will happen again
here is the link for the data file :

@dudua

Please use following code snippet before saving the PDF. Hope this helps you.

foreach (Section section in document.Sections)
{
    section.PageSetup.HeaderDistance = 0;
}

document.LastSection.Body.LastParagraph.ParagraphBreakFont.ClearFormatting();
document.LastSection.Body.LastParagraph.ParagraphFormat.ClearFormatting();
document.LastSection.Body.LastParagraph.ParagraphBreakFont.Size = .5;

document.UpdatePageLayout();
document.Save(Context.Output, AsposeHelper.GetSaveFormat(Context.OutputFormat));

thanks for the response the seems to solve the issue , i i also have a performance issue , when i am working with a large data set , should i open a new post or , we can continue on this thread

@dudua,

Thanks for your inquiry. It is better to open a new thread to keep relevant discussions separate. Please share your input, output documents, XML file (dataset) and standalone console application in your new thread for testing.

Best regards,
Awais Hafeez