Remove tab (\t) and new lines (\n) at the end of footer content


If there is doc or docx file with a footer that contains tab(\t) and newline (\r) at the end of footer text. And that document is converted to pdf then that creates the new blank page in new pdf.
If I open the same document with Microsoft word or OpenOffice and save as pdf it successfully converts it without adding an extra page.

Question1: Is there any configuration available that can be injected in Document object so that it trims those tabs or return characters at the end of the footer.

Question2: Before conversion, if I want to trim those from the content of footer keeping all the formatting of the footer, how can I do that? I managed to get HeaderFooter object and collection of paragraphs in it, but could not find any example to update content without losing the original formatting,

Issue tested with today’s (08/31/2017) Aspose Java and Pdf lib too.

Kindly let me know the answers with your earliest convenience.
Thank you.



Thanks for your inquiry. We will appreciate it if you please ZIP and attach the following resources here for testing. We will look into the issue and will guide you accordingly.

  • Your input Word document
  • Your output Pdf document
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.


Hi Tilal,

Thanks for the response.

Please find the attached zip for requested documents. (43.9 KB)

Please let me know if you need anything else.




Thanks for sharing the documents. But I am afraid I am unable to notice any extra page in resultant PDF. Your source word document contains 11 pages and Aspose.Words,MS Word and Open Office all render 11 page PDF document. We will appreciate it if you please share your expected document here, it will help us to address your issue exactly.

Footer_Document_openoffice.pdf (67.2 KB)
Footer_Document_AW178.pdf (68.3 KB)
Footer_Document_MSW.pdf (283.4 KB)


Hi Tilal,

If you notice in pdf I submitted, in conversion process on
Page 2

Subject Initials _______  
is changed to

Subject Initial

Which is not the case in doc file. When I debug problem, there are \t and \r at end of footer text which if I trim, I am sure it should resolve issue.
If you can share code in which footer content of DOC file can be located fetched and trimmed and reinserted at same position, it will help me resolve issue with Aspose.

Please let me know if you have any questions.



Thanks for your feedback. You are using a quite old version of Aspose.Words for Java. We have tested the scenario with Aspose.Words for Java 17.9 and unable to notice the reported issue in page footer. Please download and try latest version of Aspose.Words for Java it will resolve the issue.
Footer_Document_AW179_.pdf (68.3 KB)


Hi Tilal,
As I mentioned in the orignal post I tried the issue with Aspose.Word released on 08/31/2017.
But If you can share code in which footer content of DOC file can be located fetched and trimmed and reinserted at the same position, it will help me resolve the issue with Aspose.




Thanks for your feedback. Please note it seems missing font issue at your end. We have tested the scenario with Aspose.Words for Java 16.7.0 and we are still unable to notice your reported issue. You can implement IWarningCallback to double check this. Please install missing fonts, hopefully it will resolve the issue.

Document doc = new Document("input.docx");
doc.setWarningCallback(new HandleDocumentWarnings());"test_AW177.pdf", com.aspose.words.SaveFormat.PDF);


class HandleDocumentWarnings implements IWarningCallback
    /// <summary>
    /// Our callback only needs to implement the "Warning" method. This method is called whenever there is a
    /// Potential issue during document procssing. The callback can be set to listen for warnings generated during document
    /// Load and/or document save.
    /// </summary>
    public void warning(WarningInfo info)
        // We are only interested in fonts being substituted.
        if (info.getWarningType() == WarningType.FONT_SUBSTITUTION)
            System.out.println("Font substitution: " + info.getDescription());


However, please find sample code snippet to trim last run of Paragraph in Document Footer.

for (HeaderFooter hf : (Iterable<HeaderFooter>) doc.getChildNodes(NodeType.HEADER_FOOTER, true)) {
	for (Paragraph para : (Iterable<Paragraph>) hf.getChildNodes(NodeType.PARAGRAPH, true)) {
		if (para.getRuns().getCount() > 0) {
			Run lastrun = para.getRuns().get(para.getRuns().getCount() - 1);


Thanks Tilal for suggesting font issue.
We verified and found that it’s font issue in Linux machine in our system, and I guess that’s why you couldn’t reproduce on your end.
Really appreciate your help.




Thanks for your feedback. It is good to know that you have managed to resolve the issue.

Please keep using Aspose.Words for Java and feel free to contact us for any further assistance.