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

Free Support Forum - aspose.com

When converting excel into pdf - footer and actual sheet content overlaps

There is already a similar ticket " When saving into pdf- footer and actual sheet content overlap" logged but there is no solution provided in the thread.

Please share what was the solution.


Well, that we as an older thread, we provided fixed version to that user in the thread (you referred).
We recommend you kindly try using our latest version/fix, i.e., Aspose.Cells v20.1.x. If you still find the issue with v20.1.x, kindly do provide your template file and output PDF file, we will check it soon.

PS. please zip the files prior attaching here.

Can you tell me which version it was fixed? I am using 18.10.


Your issue might be template specific and is not exactly the same to other issue you are referring to. As recommended earlier kindly try using our latest version/fix, i.e., Aspose.Cells v20.1.x. If you still find the issue with v20.1.x, kindly do provide your template file and output PDF file, we will check it soon.

test.zip (65.5 KB)

test.zip contains the excel file that I’m trying to convert to PDF and below is the code that I’m writing to convert excel to PDF.

       var tempMemoryStream = new MemoryStream();
       Workbook workbook = new Workbook(new MemoryStream(fileData));

        foreach (Worksheet sheet in workbook.Worksheets)
            sheet.PageSetup.Orientation = PageOrientationType.Portrait;
            sheet.PageSetup.FitToPagesWide = 1;
            sheet.PageSetup.FitToPagesTall = 0;

        workbook.Save(tempMemoryStream, Aspose.Cells.SaveFormat.Pdf);
        return tempMemoryStream ;

Report X.pdf is the output PDF file.
Report X.pdf (405.7 KB)


Thanks for the template file, sample code and PDF document.

I checked your template file and found there is no footer “Value 10 BOOK FOOTER” in the workbook. Do you add it dynamically or you attached the wrong file to the thread? Please either provide a template file containing your mentioned footer in it (using e.g PageSetup|Header/Footer) or provide complete code (runnable) on how you are adding footer to the workbook dynamically via Aspose.Cells APIS, so we could evaluate your issue precisely to consequently figure it (if found) out soon.

Ok we are trying to combine text/pdf/images into one PDF document. Once that document is generated, we add header and footer if it is configured by the user.
So Yes, we add header/footer dynamically to the generated PDF.

Here is the code for header/footer

  private void AddHeader(Document document, string headerHtml)
        var htmlFragment = new HtmlFragment(headerHtml);

        HeaderFooter header;
        foreach (Page page in document.Pages)
            header = new HeaderFooter();

            Table headerTable = new Table();
            headerTable.ColumnWidths = "100%";
            headerTable.Border = new BorderInfo(BorderSide.Bottom, 0.2F, Color.Black);
            headerTable.HorizontalAlignment = HorizontalAlignment.Center;

            Aspose.Pdf.Row row = headerTable.Rows.Add();

            var cell = row.Cells.Add();
            cell.Alignment = HorizontalAlignment.Center;
            page.Header = header;

    private void AddFooter(Document document, string footerHTML)
        var htmlContent = new HtmlFragment(footerHTML);

        HeaderFooter footer = null;

        foreach (Page page in document.Pages)
            footer = new HeaderFooter();

            Table footerTable = new Table();
            footerTable.ColumnWidths = "100%";
            footerTable.Border = new BorderInfo(BorderSide.Top, 0.5F, Color.Blue);

            // Add row to table
            Aspose.Pdf.Row row = footerTable.Rows.Add();
            //row.BackgroundColor = Color.Blue;

            // Add table cells
            var cell = row.Cells.Add();
            cell.Alignment = HorizontalAlignment.Center;

            // cell.VerticalAlignment = VerticalAlignment.Center;

            page.Footer = footer;

FYI, Header/footer configured by user will be a html string (from rich text editor)

One more question, Is there a way to wrap excel cell content before trying to fit the sheet on a PDF page. As you can see in the uploaded excel (2nd sheet) first column content is quite large and when we try to fit the content it is very small in size.


Thanks for the code segment.

I have checked your code segment a bit. Well, since you add footer to the generated PDF document (stream) from Excel file (by Aspose.Cells) via Aspose.PDF, so I do not think if your issue have any links to Aspose.Cells APIs by any means. Even if save the PDF file physically (by Aspose.Cells), you will see it has same display when you take the print preview (after setting PageSetup options as per your code) of the sheets in MS Excel manually. You may even confirm rendering your Excel file to PDF via MS Excel manually and check/compare the output. So, please post your requirements/issue with the artifacts in Aspose.PDF forum, one of my fellow colleagues from Aspose.PDF team will help you there.

Yes, Aspose.Cells supports text wrapping as per MS Excel, see the document with example for your reference:

Hope, this helps a bit.