Calculate page height taking into account the header/footer heights

Hey support,

how can one programatically determine the available page height, taking into account the header/footer heights? The current formula that I use is below and it results in images overflowing the footer

actualPageWidth = docBuilder.getPageSetup().getPageHeight() - (docBuilder.getPageSetup().getTopMargin() + docBuilder.getPageSetup().getBottomMargin());

Thanks and regards,
Dragos

Hi Dragos,


Thanks for your inquiry. Your code is correct. I am afraid, after an initial test with Aspose.Words 13.8.0, I was unable to reproduce this issue on my side. I have attached sample input/output Word documents here for your reference. I used the following code to generate “output.docx”.
Document doc = new Document(“C:\Temp\input.docx”);
DocumentBuilder docBuilder = new DocumentBuilder(doc);

double actualPageWidth = docBuilder.getPageSetup().getPageWidth() - (docBuilder.getPageSetup().getLeftMargin() + docBuilder.getPageSetup().getRightMargin());
double actualPageHeight = docBuilder.getPageSetup().getPageHeight() - (docBuilder.getPageSetup().getTopMargin() + docBuilder.getPageSetup().getBottomMargin());
docBuilder.insertImage(“C:\Temp\Aspose.Words.png”, actualPageWidth, actualPageHeight);

doc.save(“C:\Temp\output.docx”);

Could you please attach your input/output Word documents along with your source code here for testing? We will investigate the issue further on our end and provide you more information.

Best regards,