0

I'm using Aspose.Cells to create a report to be exported to both Excel and PDF. In cell A1, I have some text that I've given a font size of 20. When I save this workbook to a PDF file, the top half of the text is getting cut off.

Here's a screenshot of the PDf file:

enter image description here

I tried adjusting the height of the first row using AutoFitRow(int), but that's not fixing my problem. My code to reproduce this is very short:

static void Main(string[] args)
{
    Program.Licenses(); //only sets licenses

    var wb = new Aspose.Cells.Workbook();
    var ws = wb.Worksheets[0];
    var cell = ws.Cells[0, 0];

    cell.Value = "Text is cutoff";

    var style = cell.GetStyle();
    style.Font.Size = 20;
    cell.SetStyle(style);

    ws.AutoFitRow(1); //doesn't prevent text cutoff

    wb.Save(@"C:\Users\guest\Desktop\file2.pdf", Aspose.Cells.SaveFormat.Pdf);
}

What am I doing wrong that is causing the top half of my text to be cutoff? the text is also getting cut off if I export to Tiff or XPS. It looks fine however if I export to XLSX.

Version Information:

  • Aspose.Cells.DLL: Runtime Version = v2.0.50727, Version = 8.1.2.0
  • Aspose.Pdf.DLL: Runtime Version = v4.0.30319, Version 9.5.0.0
user2023861
  • 8,030
  • 9
  • 57
  • 86

1 Answers1

0

This line was the problem:

ws.AutoFitRow(1); //doesn't prevent text cutoff

The argument should be zero, not one. If I change that to the below, it'll work.

ws.AutoFitRow(0);

Edit: If the cells are merged, you need to use AutoFitterOptions to tell the code to fit merged cells:

ws.AutoFitRow(0, 0, 1, new Aspose.Cells.AutoFitterOptions() { AutoFitMergedCells = true });
user2023861
  • 8,030
  • 9
  • 57
  • 86